Ejemplo n.º 1
0
 public ActionResult Register(RegisterViewModel register)
 {
     if (ModelState.IsValid)
     {
         if (!db.Users.Any(x => x.Mobile == register.Mobile))
         {
             string hash  = FormsAuthentication.HashPasswordForStoringInConfigFile(register.Password, "MD5");
             Random rnd   = new Random();
             int    myrnd = rnd.Next(100000, 900000);
             User   user  = new User()
             {
                 RoleId   = db.Roles.Max(r => r.Id),
                 Mobile   = register.Mobile,
                 Password = hash,
                 Code     = myrnd.ToString()
             };
             db.Users.Add(user);
             db.SaveChanges();
             SMSSender sms = new SMSSender();
             sms.SendSMS(register.Mobile, XamarinMVC.App_GlobalResources.Texts.RegisterSMS + Environment.NewLine + myrnd.ToString());
             return(Redirect("index"));
         }
         else
         {
             ModelState.AddModelError("Mobile", XamarinMVC.App_GlobalResources.Errors.RepeatMobile);
         }
     }
     return(View(register));
 }
Ejemplo n.º 2
0
        private void btnTestSend_Click(object sender, EventArgs e)
        {
            string     str;
            ConfigData data = LoadConfig(out str);

            if (string.IsNullOrEmpty(str) || (data == null))
            {
                ShowMsg("请先选择发送方式并填写配置信息", false);
            }
            else if (!data.IsValid)
            {
                string msg = "";
                foreach (string str3 in data.ErrorMsgs)
                {
                    msg = msg + Formatter.FormatErrorMessage(str3);
                }
                ShowMsg(msg, false);
            }
            else if ((string.IsNullOrEmpty(txtTestCellPhone.Text) || string.IsNullOrEmpty(txtTestSubject.Text)) || ((txtTestCellPhone.Text.Trim().Length == 0) || (txtTestSubject.Text.Trim().Length == 0)))
            {
                ShowMsg("接收手机号和发送内容不能为空", false);
            }
            else if (!Regex.IsMatch(txtTestCellPhone.Text.Trim(), @"^(13|15)\d{9}$"))
            {
                ShowMsg("请填写正确的手机号码", false);
            }
            else
            {
                string str4;
                bool   success = SMSSender.CreateInstance(str, data.SettingsXml).Send(txtTestCellPhone.Text.Trim(), txtTestSubject.Text.Trim(), out str4);
                ShowMsg(str4, success);
            }
        }
Ejemplo n.º 3
0
        public MainWindow()
        {
            InitializeComponent();

            diaopen = new OpenFileDialog()
            {
                Filter = "百度API配置文件|*.bxml"
            };
            diasave = new SaveFileDialog()
            {
                Filter = "百度API配置文件|*.bxml"
            };

            sms     = new SMSSender(new BCE(new BCESettings()), new SMSSettings());
            smsinfo = new SMSInfo();

            hppSms.PredefinedPropertyAttributeDictionary = new Dictionary <string, PropertyPanelAttribute>()
            {
                { "ContentVar", new PropertyPanelAttribute()
                  {
                      Order = -1
                  } }
            };

            DataContext = this;
        }
Ejemplo n.º 4
0
        private ConfigData LoadConfig(out string selectedName)
        {
            selectedName = base.Request.Form["ddlSms"];
            this.txtSelectedName.Value = selectedName;
            this.txtConfigData.Value   = "";
            if (string.IsNullOrEmpty(selectedName) || selectedName.Length == 0)
            {
                return(null);
            }
            ConfigablePlugin configablePlugin = SMSSender.CreateInstance(selectedName);

            if (configablePlugin == null)
            {
                return(null);
            }
            ConfigData configData = configablePlugin.GetConfigData(base.Request.Form);

            if (configData != null)
            {
                this.txtConfigData.Value = configData.SettingsXml;
            }

            Globals.AppendLog(new Dictionary <string, string>(), "SMSSettings-LoadConfig:" + selectedName + "," + configData.ToString(), "", "", "/log/SMSSettings.txt");
            return(configData);
        }
Ejemplo n.º 5
0
        private void HaiMeiSendMessage(SiteSettings settings, string cellphone)
        {
            try
            {
                string     text       = HiContext.Current.GenerateRandomNumber(4);
                ConfigData configData = new ConfigData(HiCryptographer.Decrypt(settings.SMSSettings));
                SMSSender  sMSSender  = SMSSender.CreateInstance(settings.SMSSender, configData.SettingsXml);
                string     text2      = string.Format(@"您好!您正在进行海美生活会员修改密码,本次的验证码为:{0},请勿向任何人提供您收到的短信验证码,并尽快完成验证。", text);
                string     text3;

                bool flag = sMSSender.Send(cellphone, text2, out text3);
                if (flag)
                {
                    //HiCache.Insert(HiContext.Current.User.UserId + "cellphone", text, 10800);
                    EcShop.Entities.Members.Verify verfyinfo = new Entities.Members.Verify();
                    verfyinfo.VerifyCode = text;
                    verfyinfo.CellPhone  = cellphone.Trim();
                    EcShop.ControlPanel.Members.TelVerifyHelper.CreateVerify(verfyinfo);
                }
                this.message = "{\"success\":true,\"msg\":\"" + text3 + "\"}";
            }
            catch (System.Exception)
            {
                this.message = "{\"success\":false,\"msg\":\"未知错误\"}";
            }
        }
Ejemplo n.º 6
0
    protected void BtnSave_Click(object sender, EventArgs e)
    {
        string s;

        if (RbtnMale.Checked == true)
        {
            s = "male";
        }
        else
        {
            s = "female";
        }
        //  string mycmd = "insert into ContactUs values('" + TxtName.Text + "','" + TxtAddress.Text + "','" + s + "','" + TxtContactNo.Text + "','" + TxtEmailAddress.Text + "','" + TxtMessage.Text + "')";
        // bool x = dm.NonQuery(mycmd);
        // if (x == true)
        // {
        Response.Write("<script>alert('Thanks for contacting Us!')</script>");
        string    msg = "Hello" + TxtName.Text + ".Thanks for enquiry.We will contact You shortly.Regards-Ebanking";
        SMSSender ss  = new SMSSender();
        bool      y   = ss.SendMySMS(TxtContactNo.Text, msg);

        if (y == true)
        {
            Response.Write("<script>alert('sucess!')</script>");
        }
        else
        {
            Response.Write("<script>alert('fali!')</script>");
        }

        // }
        //  else
        //  Response.Write("<script>alert('Error..try again!')</script>");
    }
Ejemplo n.º 7
0
    protected void btnconfirm_Click(object sender, EventArgs e)
    {
        string h    = ddlhour.SelectedItem.Value;
        string m    = ddlminute.SelectedItem.Value;
        string t    = ddltiming.SelectedItem.Value;
        string time = h + ":" + m + " " + t;
        string a    = appid.Text;

        DataBaseManager dbm = new DataBaseManager();
        string          sql = "update Appointment set Time='" + time + "', Status='Confirmed' where Id='" + a + "' ";

        if (dbm.ExecuteIUD(sql))
        {
            DataTable dt   = new DataTable();
            string    sql1 = "select * from Appointment where Id='" + a + "'";
            dt = dbm.ExecuteSelect(sql1);

            string    mobile  = dt.Rows[0]["Mobile"].ToString();
            string    name    = dt.Rows[0]["Name"].ToString();
            string    doctor  = dt.Rows[0]["Doctor"].ToString();
            string    date    = dt.Rows[0]["Date"].ToString();
            string    message = "Dear " + name + ", Your Appointment has been confirmed with " + doctor + " on " + date + " at " + time + ". Thanks";
            SMSSender sms     = new SMSSender();
            sms.SendSMS(mobile, message);
            Response.Write("<script>alert('Appointment Confirmed.');</script>");
        }
        else
        {
            Response.Write("<script>alert('Something went wrong.');</script>");
        }
    }
Ejemplo n.º 8
0
        private ConfigData LoadConfig(out string selectedName)
        {
            SiteSettings masterSettings = SettingsManager.GetMasterSettings(false);

            selectedName = masterSettings.SMSSender;
            //selectedName = base.Request.Form["ddlSms"];
            this.txtSelectedName.Value = selectedName;
            this.txtConfigData.Value   = "";
            if (string.IsNullOrEmpty(selectedName) || selectedName.Length == 0)
            {
                return(null);
            }
            ConfigablePlugin configablePlugin = SMSSender.CreateInstance(selectedName);

            if (configablePlugin == null)
            {
                return(null);
            }
            ConfigData configData = configablePlugin.GetConfigData(base.Request.Form);

            if (configData != null)
            {
                this.txtConfigData.Value = configData.SettingsXml;
            }
            return(configData);
        }
        /// <summary>
        /// Sends code in sms
        /// </summary>
        public void SendCode(string userId, string phoneNumber)
        {
            string code = GenerateSixDigitCode();

            SMSSender.SendRegular(phoneNumber, code);
            StoreUserCode(userId, code);
        }
Ejemplo n.º 10
0
        //手机发送短信验证码,调用平台接口
        static void Main(string[] args)
        {
            //using (ZSZDbContext ct=new ZSZDbContext())
            //{
            //    ct.Database.Delete();
            //    ct.Database.Create();
            //}
            //Console.WriteLine("OK");
            string userName   = "******";
            string appKey     = "8b4de3b31534437b416aaa";
            string templateId = "326";
            string code       = "6666";
            string phoneNum   = "18918918189";

            /*
             *          WebClient wc = new WebClient();
             *          string url = "http://sms.rupeng.cn/SendSms.ashx?userName="******"&appKey=" + Uri.EscapeDataString(appKey) +
             *              "&templateId=" + templateId + "&code=" + Uri.EscapeDataString(code) +
             *              "&phoneNum=" + phoneNum;
             *          wc.Encoding = Encoding.UTF8;
             *          string resp = wc.DownloadString(url);
             *          //发出url这样一个http请求(Get请求)返回值为响应报文体
             *          Console.WriteLine(resp);
             */
            SMSSender sender = new SMSSender();

            sender.AppKey   = appKey;
            sender.UserName = userName;
            var result = sender.SendSMS(templateId, code, phoneNum);

            Console.WriteLine("返回码:" + result.code + ",消息:" + result.msg);
            Console.WriteLine("ok");
            Console.ReadKey();
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 当条件为真,则发送短信或邮件。否则只记录日志。
        /// </summary>
        /// <param name="condition"></param>
        /// <param name="message"></param>
        public virtual void WarnIf(bool condition, string message)
        {
            if (condition)
            {
                string msg = String.Format("<b>{0}</b>&nbsp;&nbsp;{1}&nbsp;&nbsp;{2}<br/>", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), User, message);
                switch (LogConfig.LogWarnType)
                {
                case LogWarnType.OFF:
                    break;

                case LogWarnType.Email:
                    new Thread(new ThreadStart(() =>
                    {
                        using (Email.EmailSender sender = new Email.EmailSender()
                        {
                            Subject = "[Event Log System]",
                            EmailBody = msg
                        })
                        {
                            sender.AddReceiver(LogConfig.LogWarnEmail);
                            sender.Send();
                        }
                    })).Start();
                    break;

                case LogWarnType.SMS:
                    new Thread(new ThreadStart(() =>
                    {
                        SMSSender.Send(LogConfig.LogWarningSMSReciver, msg);
                    })).Start();
                    break;
                }
            }
            InnerLogMethod(LogLevel.Warn, message);
        }
Ejemplo n.º 12
0
        public string SendSMS(string phoneNumber)
        {
            string createdCode = GetCodeVerification();

            SMSSender.SendSMS(phoneNumber, "Doğrulama Kodu : " + createdCode);
            return("4141");
        }
Ejemplo n.º 13
0
        public bool SendSms(string phone, string text)
        {
            SMSSender sender = new SMSSender("*****@*****.**", "1qaZ2wsX", "name");
            var       result = sender.Send(phone, text);

            return(true);
        }
Ejemplo n.º 14
0
        private ConfigData LoadConfig(out string selectedName)
        {
            selectedName = base.Request.Form["ddlSms"];
            this.txtSelectedName.Value = selectedName;
            this.txtConfigData.Value   = "";
            ConfigData result;

            if (string.IsNullOrEmpty(selectedName) || selectedName.Length == 0)
            {
                result = null;
            }
            else
            {
                ConfigablePlugin plugin = SMSSender.CreateInstance(selectedName);
                if (plugin == null)
                {
                    result = null;
                }
                else
                {
                    ConfigData configData = plugin.GetConfigData(base.Request.Form);
                    if (configData != null)
                    {
                        this.txtConfigData.Value = configData.SettingsXml;
                    }
                    result = configData;
                }
            }
            return(result);
        }
Ejemplo n.º 15
0
        public static SendStatus SendSMS(string[] phoneNumbers, string message, SiteSettings settings, out string string_0)
        {
            string_0 = "";
            SendStatus result;

            if (phoneNumbers == null || string.IsNullOrEmpty(message) || phoneNumbers.Length == 0 || message.Trim().Length == 0)
            {
                result = SendStatus.RequireMsg;
            }
            else
            {
                if (settings == null || !settings.SMSEnabled)
                {
                    result = SendStatus.NoProvider;
                }
                else
                {
                    SMSSender sMSSender = Messenger.CreateSMSSender(settings, out string_0);
                    if (sMSSender == null)
                    {
                        result = SendStatus.ConfigError;
                    }
                    else
                    {
                        result = (sMSSender.Send(phoneNumbers, message, out string_0) ? SendStatus.Success : SendStatus.Fail);
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 16
0
        public SMSController(ApplicationDbContext dbContext, SMSSender smsSender, IConfiguration configuration)
        {
            _smsSender = smsSender;
            _dbContext = dbContext;

            _configuration = configuration;
        }
Ejemplo n.º 17
0
        private void GetSmsCodeCommandExecute(object obj)
        {
            SMSSender sender = new SMSSender("*****@*****.**", "1qaZ2wsX", "name");

            _generatedSmsCode = new Random().Next(9999);

            sender.Send(PhoneNumber, _generatedSmsCode.ToString());
        }
Ejemplo n.º 18
0
        public ActionResult ForgotPassword(string phoneNum,
                                           string verifyCode)
        {
            //从TempData获得图形验证码
            string serverVerifyCode = (string)TempData["verifyCode"];

            if (serverVerifyCode != verifyCode)
            {
                return(Json(new AjaxResult
                {
                    Status = "error",
                    ErrorMsg = "验证码错误"
                }));
            }
            var user = userService.GetByPhoneNum(phoneNum);

            if (user == null)
            {
                return(Json(new AjaxResult
                {
                    Status = "error",
                    ErrorMsg = "没有这个手机号"
                }));
            }
            string appKey   = settingService.GetValue("如鹏短信平台AppKey");
            string userName = settingService.GetValue("如鹏短信平台UserName");
            string tempId   = settingService.GetValue("如鹏短信平台找回密码短信模板Id");
            //生成一个4位的短信验证码
            string smsCode = new Random().Next(1000, 9999).ToString();
            //发送短信
            SMSSender smsSender = new SMSSender();

            smsSender.AppKey   = appKey;
            smsSender.UserName = userName;
            var sendResult = smsSender.SendSMS(tempId, smsCode, phoneNum);

            //如果发送成功
            if (sendResult.code == 0)
            {
                //把发送短信的时候存入TempData
                TempData["ForgotPasswordPhoneNum"] = phoneNum;
                //发送给手机的验证码也存入TempData
                TempData["SmsCode"] = smsCode;
                return(Json(new AjaxResult {
                    Status = "ok"
                }));
            }
            else
            {
                return(Json(new AjaxResult
                {
                    Status = "error",
                    ErrorMsg = sendResult.msg
                }));
            }
        }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string       name     = TextBox1.Text;
        string       age      = TextBox2.Text;
        string       mobile   = TextBox3.Text;
        string       gender   = RadioButtonList1.SelectedItem.Text;
        string       email    = TextBox4.Text;
        string       password = TextBox5.Text;
        CryptoGraphy cg       = new CryptoGraphy();

        password = cg.MD5Hash(password);
        string specialmedical = TextBox6.Text;

        Random rnd = new Random();

        string otp       = rnd.Next(100000, 999999).ToString();
        bool   otpstatus = false;

        string date = DateTime.Now.ToString("MM/dd/yyyy");
        string time = DateTime.Now.ToString("HH:mm:ss");

        DataBaseManager dbm = new DataBaseManager();

        string    checkemail = "select * from RegistrationTbl where Email='" + email + "'";
        DataTable dt         = new DataTable();

        dt = dbm.ExecuteSelect(checkemail);
        if (dt.Rows.Count > 0)
        {
            Response.Write("<script>alert('Email ID is already registered. Please use another Email ID')</script>");
        }
        else
        {
            string query = "insert into RegistrationTbl(Name,Age,Mobile,Gender,Email,Password,SpecialMedicalCondition,OTP,OTPStatus,Date,Time) values('" + name + "','" + age + "','" + mobile + "','" + gender + "','" + email + "','" + password + "','" + specialmedical + "','" + otp + "','" + otpstatus + "','" + date + "','" + time + "')";
            if (dbm.ExecuteIUD(query))
            {
                // send OTP and Redirect to OTP Verification page

                SMSSender sms     = new SMSSender();
                string    message = "Dear " + name + ", Your OTP Verification Code is - " + otp;
                bool      smsst   = sms.SendSMS(mobile, message);

                // Create Session for OTP Verification

                Session["RegEmail"] = email;

                Response.Write("<script>alert('Data Saved. We have sent you OTP Code, Please enter to proceed.'); window.location.href='OTPVerification.aspx';</script>");
            }
            else
            {
                // Query Error
                Response.Write("<script>alert('Something went wrong, please try again leter, some technical issue.')</script>");
            }
        }
    }
Ejemplo n.º 20
0
        public void Execute(IJobExecutionContext context)
        {
            Task.Factory.StartNew(() =>
            {
                try
                {
                    //获取所有待发送短信报警
                    var listSms = JobDbAssist.Instance.GetWaitSendMessageQueue((int)eMessageType.SMS);

                    if (listSms.Count() == 0)//Job新报警空闲时(暂无新告警)
                    {
                        //重发之前发送异常的数据
                        listSms = JobDbAssist.Instance.GetWaitAgainSendMessageQueue((int)eMessageType.SMS);
                    }

                    if (listSms.Count() > 0)
                    {
                        //更新短信发送数量
                        JobDispatch.UISMSCount?.Invoke(listSms.Count());

                        foreach (VMessageQueye item in listSms)
                        {
                            //设置状态为发送中
                            JobDbAssist.Instance.SetSMSMessageQueueStatus(item.ID, (int)eSendStatus.Sending);

                            //需要短信模板转换-> [发送]
                            string resultMsgJson = new SMSSender().Sender(item.Mobile, item.MessageContent);

                            EResultMessage resultMsg = resultMsgJson.ToObject <EResultMessage>();

                            //反馈码
                            string resultMsgCode = resultMsg.Code.ToLower();

                            //根据反馈消息设置MessageQueye 反馈字段ResultMessage  和 Send 状态
                            JobDbAssist.Instance.SetSMSResultSendMessageQueue(item.ID, resultMsgJson, resultMsgCode == "ok");

                            if (resultMsgCode == "ok")
                            {
                                JobDispatch.UISMSCount?.Invoke(1);
                                JobDispatch.UIDispalyTask("{0} 【短信发送】".Format(context.JobDetail.Key.Name), "发送成功", (int)eJobStatus.OK);
                            }
                            else
                            {
                                JobDispatch.UIDispalyTask("{0} 【短信发送】".Format(context.JobDetail.Key.Name), "发送失败", (int)eJobStatus.Fault);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.WriteFormat("A-【SMSSendJob 短信发送异常】Job异常:{0}", ex.Message);
                    JobDispatch.UIDispalyTask("{0} 【短信发送异常】".Format(context.JobDetail.Key.Name), ex.Message, (int)eJobStatus.Exception);
                }
            });
        }
Ejemplo n.º 21
0
 public static void SendNotification(string title, string body, string to, NotificationMedia media)
 {
     if (media == NotificationMedia.Email)
     {
         EmailSender.Send(ConfigurationManager.AppSettings["ParkingApi.Messaging.Email.From"], to, title, body);
     }
     else
     {
         SMSSender.Send(to, body);
     }
 }
Ejemplo n.º 22
0
        public OperationResult AfterStartServerAuthentication(string applicationUser, string tokenID, string baseNotifyMessage, string newPassword, TokenMovingFactorType tokenMovingFactorType, TokenSeedType tokenSeedType)
        {
            string[] _arrayNotifMsg = (baseNotifyMessage ?? "").Split(new char[]
            {
                '|'
            });
            string[] _params = new string[_arrayNotifMsg.Length - 1];
            Array.Copy(_arrayNotifMsg, 1, _params, 0, _params.Length);
            string notifMsg = ((_arrayNotifMsg[0] ?? "").Length > 1) ? _arrayNotifMsg[0] : SAFConfiguration.readParameterExternal("SMS.TEMPLATE.ON.STARTSERVERAUTH");

            notifMsg = string.Format(notifMsg.Replace("{tm}", DateTime.Now.ToShortDateString()).Replace("{dt}", DateTime.Now.ToShortTimeString()), _params);
            return(SMSSender.Send(applicationUser, tokenID, null, notifMsg));
        }
Ejemplo n.º 23
0
    protected void BtnSend_Click(object sender, EventArgs e)
    {
        SMSSender ss = new SMSSender();

        if (ss.SendMySMS(TxtMobNo.Text, TxtMessage.Text) == true)
        {
            Response.Write("<script>alert('SMS sent successfully')</script>");
        }
        else
        {
            Response.Write("<script>alert('SMS sent not successfully')</script>");
        }
    }
Ejemplo n.º 24
0
        public AccountCheckings(string accountNumber) : base(accountNumber)
        {
            this.setAccountNumber(accountNumber);
            this.setInterestType(new Promotion3(new Promotion2(new InterestCalcBy1000(this)))); //

            Logger      log   = new Logger(this);
            SMSSender   sms   = new SMSSender(this);
            EmailSender email = new EmailSender(this);

            String oldValue = accountNumber;

            //this.setChanged();
            this.NotifyObservers(new ChangedSender("created", oldValue, ""));
        }
Ejemplo n.º 25
0
        public async Task <ActionResult> UpdateSessionStatus(int Id, string Name, string UserId = "")
        {
            try
            {
                if (Name == "Delete")
                {
                    await _tutorService.DeleteSession(Id);
                }
                else
                {
                    if (string.IsNullOrEmpty(UserId) || UserId == "0")
                    {
                        UserId = User.Identity.GetUserId();
                    }

                    var result = await _tutorService.ApproveDeclineSession(Id, new Sessions()
                    {
                        Status           = Name == "Approve" ? SessionStatus.Approved : SessionStatus.Declined,
                        ApproveDeclineBy = UserId
                    });

                    if (result.Item1)
                    {
                        try
                        {
                            var _session = result.Item2;
                            var _status  = Name == "Approve" ? "Aprroved" : "Declined";
                            var _subject = _status + " Session Request | instanttutors.org";
                            var _body    = "<h3>Session request has been " + _status + ".</h3>"
                                           + "<b>Session Title:</b> " + _session.Title + "<br/>"
                                           + "<b>Description <small>(If Any)</small>:</b> " + _session.Description + "<br/>"
                                           + "<b>Communication Method:</b> " + _session.CommunicationMethod + "<br/><br/>"
                                           + "<a href='http://instanttutors.org/' target='_blank'>Instant Tutors</a> Team @" + DateTime.Now.Year;

                            await EmailSender.SendEmailAsync(_subject, _body);

                            await SMSSender.SMSSenderAsync(_session.Title + " Session request has been " + _status + ".");
                        }
                        catch (Exception ex1)
                        {
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 26
0
        public static IMessageSender CreateMessageSender()
        {
            IMessageSender retVal;
            string         messageSender = "SMS"; //ConfigurationManager.AppSettings["message"].ToString();

            if (messageSender == "SMS")
            {
                retVal = new SMSSender();
            }
            else
            {
                retVal = new MailSender();
            }
            return(retVal);
        }
    protected void Sendbtn_Click(object sender, EventArgs e)
    {
        SMSSender ms = new SMSSender();
        bool      x  = ms.SendSMS(txtMobNo.Text, txtMsg.Text);

        if (x == true)
        {
            txtMobNo.Text = "";
            txtMsg.Text   = "";
            Response.Write("<script>alert('SMS Sent Successfully.')</script>");
        }
        else
        {
            Response.Write("<script>alert('Unable To Send SMS.')</script>");
        }
    }
Ejemplo n.º 28
0
    protected void BtnSendSMS_Click(object sender, EventArgs e)
    {
        SMSSender mss = new SMSSender();
        bool      x   = mss.SendSMS(TxtMobNo.Text, TxtMsg.Text);

        if (x == true)
        {
            TxtMsg.Text   = "";
            TxtMobNo.Text = "";
            Response.Write("<script>alert('SMS Sent Successfully')</script>");
        }
        else
        {
            Response.Write("<script>alert('Unable To Send SMS')</script>");
        }
    }
Ejemplo n.º 29
0
    protected void BtnSendSMS_Click(object sender, EventArgs e)
    {
        SMSSender ss = new SMSSender();
        bool      b  = ss.SendMySMS(TxtMobNo.Text, TxtMessage.Text);

        if (b == true)
        {
            TxtMessage.Text = "";
            TxtMobNo.Text   = "";
            Response.Write("<script>alert('SMS Sent.');</script>");
        }
        else
        {
            Response.Write("<script>alert('SMS not Sent.');</script>");
        }
    }
Ejemplo n.º 30
0
        /// <summary>
        /// 验证手机和图形验证码,然后发送短信
        /// </summary>
        /// <param name="phoneNum">手机</param>
        /// <param name="verifyCode">图形验证码</param>
        /// <returns></returns>
        public ActionResult SendSmsVerifyCode(string phoneNum, string verifyCode)
        {
            string serverVerifyCode = (string)TempData["verifyCode"];//取服务器中保存的图形验证码

            if (serverVerifyCode != verifyCode)
            {
                return(Json(new AjaxResult {
                    Status = "error", ErrorMsg = "图形验证码填写错误"
                }));
            }
            //配置信息从T_Settings 表读取
            string appKey   = settingService.GetValue("如鹏短信平台AppKey");
            string userName = settingService.GetValue("如鹏短信平台UserName");
            string tempId   = settingService.GetValue("如鹏短信平台注册短信模板Id");

            //短信验证码一般都是数字
            string smsCode = new Random().Next(1000, 9999).ToString();

            TempData["smsCode"] = smsCode;//给ActionResult Register(UserRegModel model)用

            //发送短信
            SMSSender smsSender = new SMSSender();

            smsSender.AppKey   = appKey;
            smsSender.UserName = userName;
            var sendResult = smsSender.SendSMS(tempId, smsCode, phoneNum);

            //发送成功
            if (sendResult.code == 0)
            {
                //把发送验证码的手机号放到TempData,在注册的时候再次检查一下注册的是不是这个手机号
                //防止网站漏洞
                TempData["RegPhoneNum"] = phoneNum;

                return(Json(new AjaxResult {
                    Status = "ok"
                }));
            }
            else
            {
                return(Json(new AjaxResult
                {
                    Status = "error",
                    ErrorMsg = sendResult.msg
                }));
            }
        }
Ejemplo n.º 31
0
        /*Перевіряє введення номера по ходу його зміни. Задає OperatorID.
        * Створє нові обєкти sender'ів в залежності від повноти введеного номера*/
        private void ValidatePhoneNumber()
        {
            Regex isPhoneNumber = new Regex(@"^0(50|66|95|99|67|96|97|98|68|39)(\d{0,7})$");
            if (isPhoneNumber.IsMatch(PhoneNumber))//Якщо є номером або початком номера
            {
                var number = isPhoneNumber.Match(PhoneNumber);//Номер без коду оператора
                string code = number.Groups[1].Value;
                switch (code)
                {
                    case "50":
                    case "66":
                    case "95":
                    case "99": ActivateOperatorImages(true, false, false, false); break;
                    case "67": ActivateOperatorImages(false, true, false, false); break;
                    case "96":
                    case "97":
                    case "98": ActivateOperatorImages(false, false, true, false); break;
                    case "39":
                    case "68": ActivateOperatorImages(false, false, false, true); break;
                }

                List<string> MTScodes = new List<string>(new string[] { "50", "66", "95", "99" });//Коди МТС
                bool isMTS = MTScodes.Contains(code);
                //Визначаємо CurrentOperator на основі перших 3 цифр номеру, незалежно чи він введений до кінця
                CurrentOperator = isMTS ? Operator.MTS : Operator.Kyivstar;
                if (number.Groups[2].Value.Length == 7)//Якщо вже введений весь номер
                {
                    if (isMTS) Sender = mtsSender; /*****************************************/
                    else Sender = kyivstarSender;
                }
                else
                {
                    //if (number.Groups[1].Value.Length < 2)
                    //{
                        /* міняємо сендера коли міняємо оператора. так менше глючить коли нема інтернету */
                        Sender = null; //При зміні номера, навіть не повністю, видалаємо sender'а
                    //}
                }
            }
            else//При видаленні навіть тієї частини де код оператора занулення всього
            {
                ActivateOperatorImages(false, false, false, false);
                CurrentOperator = Operator.Undefined;
                Sender = null;
            }
        }
Ejemplo n.º 32
0
    protected void btnSave_OnClick(object sender, EventArgs e)
    {
        string researchid = txtResearchList.Text;
        if(string.IsNullOrWhiteSpace(researchid) && !CheckBox1.Checked)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء اختيار باحث على الاقل\")</SCRIPT>", false);
            return;
        }
        if (string.IsNullOrWhiteSpace(txtSubject.Text))
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء ادخال عنوان الرسالة\")</SCRIPT>", false);
            return;
        }
        if (string.IsNullOrWhiteSpace(txtTxt.Text))
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.error(\"الرجاء ادخال  الرسالة\")</SCRIPT>", false);
            return;
        }
        Database db=new Database();
        DataTable dt;

        if(!CheckBox1.Checked)
        {
            dt = db.ExecuteDataTable("select * from Researcher where isAproved=1 and (id in (" + researchid + "))");
        }
        else
        {
            dt = db.ExecuteDataTable("select * from Researcher where isAproved=1");
        }
        List<string> to=new List<string>();
        AppFunctions validate=new AppFunctions();
        foreach (DataRow row in dt.Rows)
        {
            if(RadioButtonList1.SelectedValue.Equals("1"))
            {
                if (validate.IsEmailValid(row["email"].ToString()))
                {
                    to.Add(row["email"].ToString());
                }
            }
            else
            {
                if (validate.IsPhoneValid(row["phone"].ToString()))
                {
                    to.Add(row["phone"].ToString());
                }
            }
        }

        if (RadioButtonList1.SelectedValue.Equals("1"))
        {
            SendMail mail = new SendMail();
            mail.SendMsg(to, txtSubject.Text, txtTxt.Text);
            ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.success(\"تم ارسال رسالة بريد الالكتروني الى الباحثين و عددهم " + dt.Rows.Count+"\")</SCRIPT>", false);
        }
        else
        {
            Tools t = new Tools();
            SMSSender sms = new SMSSender();
            sms.Message = txtTxt.Text;
            sms.SendSms(to);
            ScriptManager.RegisterStartupScript(this, this.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.success(\"تم ارسال رسالة نصية الى الباحثين و عددهم " + dt.Rows.Count + "\")</SCRIPT>", false);
        }
    }