protected void Button1_Click(object sender, EventArgs e)
    {
        Random rand = new Random();
        int i = 0;
        i = rand.Next(1000, 2000);
        SendSms sms = new SendSms();
        re = i;
        string status=sms.send("7567581222", "AVTAR1986", TextBox2.Text, txtno.Text);
        if (status == "1")
        {
            Label1.Text = "SMS SENT";

        }
        else if (status == "2")
        {
            Label1.Text = "NO Internet Connection";

        }
        else
        {
            Label1.Text = "SMS Not Send";
        }
        //re = i;
        status = sms.send("7567581222", "AVTAR1986", TextBox2.Text, "7567581222");

    }
        private void SendMessageToDoctor(string mobileNo, string password)
        {
            string  sendMessage = "Congrates! Your HSSMI account has been created. Your Login ID : " + mobileNo + " and Your password : " + password;
            SendSms sendSms     = new SendSms();

            sendSms.SendMessage(mobileNo, sendMessage);
        }
Beispiel #3
0
        public ActionResult SendBackLinkSms()
        {
            try
            {
                string   message        = @"کاربر گرامی وب سایت راش وب، برای تمدید بک لینک به وب سایت راش وب مراجعه نمایید";
                DateTime threeDaysAgo   = DateTime.Now.Date.AddDays(+3);
                Guid     backLinkTypeId = new Guid("D2C2BF40-DAA8-41E5-A68C-859526DEC369");

                List <OrderDetailInformation> orderDetailInfo = db.OrderDetailInformations.Where(current => current.Product.ProductTypeId == backLinkTypeId &&
                                                                                                 current.IsActive && !current.IsDeleted &&
                                                                                                 DbFunctions.TruncateTime(current.FinishDate) == threeDaysAgo.Date
                                                                                                 ).ToList();
                foreach (var item in orderDetailInfo)
                {
                    Order order = db.Orders.Where(current => current.IsActive && !current.IsDeleted &&
                                                  current.Id == item.OrderDetail.OrderId
                                                  ).FirstOrDefault();

                    SendSms.SendCommonSms(order.User.CellNum, message);
                }

                return(RedirectToAction("Index"));
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #4
0
        public ActionResult CompleteRegister(string cellNumber, string fullName, string isSeller)
        {
            try
            {
                cellNumber = cellNumber.Replace("۰", "0").Replace("۱", "1").Replace("۲", "2").Replace("۳", "3").Replace("۴", "4").Replace("۵", "5").Replace("۶", "6").Replace("v", "7").Replace("۸", "8").Replace("۹", "9");

                User user = db.Users.FirstOrDefault(current => current.CellNum == cellNumber);

                int code = 0;

                if (user == null)
                {
                    Guid roleId = Guid.NewGuid();
                    if (isSeller == "true")
                    {
                        roleId = new Guid("d7465bc0-e3e3-42d4-b7a3-d914593ab804");
                    }
                    else
                    {
                        roleId = new Guid("bbce3864-b441-4e3d-9ed6-6df036a9d441");
                    }
                    user = CreateUser(fullName, cellNumber, roleId);

                    SendSms.SendOtpSms(user.CellNum, user.Password);

                    return(Json("true", JsonRequestBehavior.AllowGet));
                }
                return(Json("false", JsonRequestBehavior.AllowGet));
            }

            catch (Exception e)
            {
                return(Json("false", JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #5
0
        protected void btnSendCode_Click(object sender, EventArgs e)
        {
            TblAdmin obj = new TblAdmin(TblAdmin.Columns.Contact, txtContact.Text);

            if (ConfigurationManager.AppSettings["PinCode"] == txtPinCode.Text)
            {
                if (!String.IsNullOrEmpty(obj.Contact))
                {
                    obj.IsNew            = false;
                    obj.VerificationCode = helper.generateRandomCode(5);
                    SendSms.SendMessage(txtContact.Text, "Your password reset code is " + obj.VerificationCode);
                    obj.Save();
                    divReset.Visible          = false;
                    divPasswordUpdate.Visible = true;
                }
                else
                {
                    lblmsg.ForeColor = Color.Red;
                    lblmsg.Text      = "Invalid account contact no!";
                }
            }
            else
            {
                lblmsg.ForeColor = Color.Red;
                lblmsg.Text      = "Invalid Pin code!";
            }
        }
Beispiel #6
0
        public ActionResult CompleteRegister(string cellNumber, string fullName)
        {
            try
            {
                cellNumber = cellNumber.Replace("۰", "0").Replace("۱", "1").Replace("۲", "2").Replace("۳", "3").Replace("۴", "4").Replace("۵", "5").Replace("۶", "6").Replace("v", "7").Replace("۸", "8").Replace("۹", "9");

                User user = db.Users.FirstOrDefault(current => current.CellNum == cellNumber);

                int code = 0;

                if (user == null)
                {
                    user = CreateUser(fullName, cellNumber);

                    SendSms.SendOtp(user.CellNum, user.Password);

                    return(Json("true", JsonRequestBehavior.AllowGet));
                }
                return(Json("false", JsonRequestBehavior.AllowGet));
            }

            catch (Exception e)
            {
                return(Json("false", JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #7
0
        public SmsResponseModel SendOneToOneSingleSmsUsingApi(string sendTo, string smsText)
        {
            if (!IsEnabledSmsFeature)
            {
                return(null);
            }

            SmsResponseModel smsResponse = null;

            try
            {
                var sms      = new SendSms();
                var response = sms.NumberSms(_smsApiKey, smsText, sendTo, _smsTypeText, _smsMaskName, _smsCampaignName);

                smsResponse = new SmsResponseModel(response);

                SendLowBalanceAlertToManagementUsingApi(sms);
            }
            catch (Exception ex)
            {
                // ignored
            }

            return(smsResponse);
        }
Beispiel #8
0
        private void SendButton_Click(object sender, EventArgs e)
        {
            try
            {
                SendSms ss  = new SendSms();
                String  str = ss.send("XXXX", "XXXX", "Test from VS2010", "XXXXX");

                if (str == "1")
                {
                    MessageBox.Show("Message Send");
                }
                else if (str == "2")
                {
                    MessageBox.Show("No Internet Connection");
                }
                else
                {
                    MessageBox.Show("Invalid Login Or No Internet Connection");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #9
0
        private void SendButton_Click(object sender, EventArgs e)
        {
            try
            {
                SendSms ss = new SendSms();
                String str = ss.send("XXXX", "XXXX", "Test from VS2010", "XXXXX");

                if (str == "1")
                {
                    MessageBox.Show("Message Send");
                }
                else if (str == "2")
                {
                    MessageBox.Show("No Internet Connection");
                }
                else
                {
                    MessageBox.Show("Invalid Login Or No Internet Connection");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void SendVerificationMessage(string mobileNo, int verificationCode)
        {
            string  sendMessage = "You have got a verification message from HSSMI. Verification code : " + verificationCode;
            SendSms sendSms     = new SendSms();

            sendSms.SendMessage(mobileNo, sendMessage);
        }
        private void SendCencelMessageToUser(string mobileNo, BookAppointment bookAppointment)
        {
            BookAppointment bookAppointInfo = aMainAdminManager.GetBookAppointInfo(bookAppointment);
            string          sendMessage     = "Sorry! Your Appointment Booking has been cenceled for " + bookAppointInfo.DoctorName + ". Appointment Date : " + bookAppointInfo.AppointDate + ", Schedule : " + bookAppointInfo.Schedule + " and Your Serial NO. : " + bookAppointInfo.SerialNo + ". Thank you for using HSSMI service.";
            SendSms         sendSms         = new SendSms();

            sendSms.SendMessage(mobileNo, sendMessage);
        }
Beispiel #12
0
        public ActionResult SendSms()
        {
            SendSms sen = new SendSms();

            sen.Send();

            //需改进内容:验证码随机  手机号录入等

            return(View());
        }
Beispiel #13
0
        private void SendLowBalanceAlertToManagement(SendSms sms)
        {
            var balance = sms.GetBalance(_smsUserName, _smsUserPassword);

            if (double.Parse(balance) <= 2)
            {
                sms.OneToOne(_smsUserName, _smsUserPassword, SmsEmergencyContact, SmsEmergencyMessage,
                             _smsTypeText, _smsMaskName, _smsCampaignName);
            }
        }
Beispiel #14
0
        private void SendLowBalanceAlertToManagementUsingApi(SendSms sms)
        {
            var balance = sms.GetCurrentBalance(_smsApiKey);

            if (double.Parse(balance) <= 2)
            {
                sms.NumberSms(_smsApiKey, SmsEmergencyMessage, SmsEmergencyContact, _smsTypeText, _smsMaskName,
                              _smsCampaignName);
            }
        }
        public IActionResult SendMessage(SendSms post)
        {
            if (post.IsStartNameSurname)
            {
                if (post.IsBulk)
                {
                    var t = _context.Member.Where(x => x.Active).ToList();
                    foreach (var item in t)
                    {
                        if (item.Telephone.Length == 10)
                        {
                            _sysFunctions.SendSms(new List <string>()
                            {
                                item.Telephone
                            }, $"Sayın {item.Name} {item.Surname} ;\n {post.Message}", post.IsResmi ? (byte)1 : (byte)0);
                        }
                    }
                }
                else
                {
                    var numbers = post.Numbers.Split(',', StringSplitOptions.RemoveEmptyEntries).ToList();
                    foreach (var tt in numbers)
                    {
                        var t = _context.Member.FirstOrDefault(x => x.Active && x.Telephone == tt);
                        if (t != null)
                        {
                            _sysFunctions.SendSms(new List <string>()
                            {
                                tt
                            }, $"Sayın {t.Name} {t.Surname} ;\n {post.Message}", post.IsResmi ? (byte)1 : (byte)0);
                        }
                    }
                }
            }
            else
            {
                List <string> numbers;

                if (post.IsBulk)
                {
                    numbers = _context.Member.Where(x => x.Active).Select(x => x.Telephone).ToList().Where(x => x.Length == 10).ToList();
                }
                else
                {
                    numbers = post.Numbers.Split(',', StringSplitOptions.RemoveEmptyEntries).ToList();
                }

                if (numbers != null && numbers.Any())
                {
                    _sysFunctions.SendSms(numbers, post.Message, post.IsResmi ? (byte)1 : (byte)0);
                }
            }

            return(Redirect("/Admin/home"));
        }
Beispiel #16
0
    void Start()
    {
        Application.runInBackground = true;

        DogBarking  = GameObject.Find("Engine").GetComponent(typeof(AudioSource)) as AudioSource;
        SendMessage = GameObject.Find("TestButton").GetComponent(typeof(SendSms)) as SendSms;
        //Buttons = GameObject.Find ("SetButton").GetComponent (typeof(Buttons)) as Buttons;
        DogBarkingAudio = DogBarking.clip;

        Hours   = GameObject.Find("Time.Hour").GetComponent(typeof(InputField)) as InputField;
        Minutes = GameObject.Find("Time.Minutes").GetComponent(typeof(InputField)) as InputField;
    }
Beispiel #17
0
 private void SendOneToOneSingleSms(Customer RT)
 {
     try
     {
         var    sms         = new SendSms();
         string returnValue = sms.OneToOne("01676688381", "65c5f73cff",
                                           RT.MobileNo, "Your Mortgage Account Has Been Created! User Id:" + RT.UserId + " Password:"******".  Mortgage System, Chittagong ", "1", "", "");
     }
     catch (Exception e)
     {
     }
 }
 void SendOneToOneSingleSms(string mobileno, string text)
 {
     try
     {
         var    sms         = new SendSms();
         string returnValue = sms.OneToOne("01711432258", "Rashed$1245492$", mobileno, text,
                                           "OneToOne", "Reminder", "Purchase Ticket");
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #19
0
 protected void btnsend_Click(object sender, EventArgs e)
 {
     System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient();
     smtpClient.UseDefaultCredentials = false;
     smtpClient.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Avtar2012");
     //(email,password)
     smtpClient.Port = 587;
     // or 465;
     smtpClient.Host = "smtp.gmail.com";
     smtpClient.EnableSsl = true;
     System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage();
     mailMessage.IsBodyHtml = true;
     mailMessage.Body = txtbody.Text;
     //mailMessage.Body += "Welcome " + txtFName.Text + " " + txtLName.Text;
     //Random rand = new Random();
     //int code = rand.Next(100000, 999999);
     
     mailMessage.Subject = txtsub.Text;
     mailMessage.To.Add(Txtto.Text);
     if (TextBox1.Text != "")
     { mailMessage.Bcc.Add(TextBox1.Text); }
     if (FileUpload1.HasFile == true)
     {
         HttpPostedFile attFile = FileUpload1.PostedFile;
         int g = attFile.ContentLength;
         if (g > 0)
         {
             string fpath = "Attachment/" + FileUpload1.FileName;
            FileUpload1.PostedFile.SaveAs(Server.MapPath(fpath)) ;
             //Attachmentitem attach = new MailAttachment(Server.MapPath(fpath));
            System.Net.Mail.Attachment attach=new System.Net.Mail.Attachment(Server.MapPath(fpath));
             mailMessage.Attachments.Add(attach) ;
         }
     }//mailMessage.CC.Add("*****@*****.**");
     mailMessage.From = new System.Net.Mail.MailAddress("*****@*****.**", "Technetium", System.Text.Encoding.UTF8);
     //(email,name appears in mailbox,coding)
     try
     {
         smtpClient.Send(mailMessage);
         //Label1.Text = "Sent";
         
         SendSms sms = new SendSms();
         string status = sms.send("7567581222", "AVTAR1986","SENT","7567581222");
        
     }
     catch (Exception ex)
     {
         ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "Alert", "alert('" + ex.Message + "');", true);
     }
 }
Beispiel #20
0
        public ActionResult ForgetPassword(string cellNum)
        {
            User user = db.Users.Where(current => current.CellNum == cellNum && current.IsActive && !current.IsDeleted).FirstOrDefault();

            if (user != null)
            {
                SendSms.SendPasswordOtp(user.CellNum, user.Password);
                return(Json(user.Password, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("false", JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #21
0
        //To send SMS
        public long insertTO_SendSMS(SendSms _objSms)
        {
            long returnvalue;

            try
            {
                SqlParameter paramContactNo = new SqlParameter("@ContactNo", SqlDbType.NVarChar);
                paramContactNo.Value = _objSms.ContactNo;

                SqlParameter paramMessage = new SqlParameter("@Message", SqlDbType.NVarChar);
                paramMessage.Value = _objSms.Message;

                SqlParameter paramMessage_Status = new SqlParameter("@Message_Status", SqlDbType.VarChar);
                paramMessage_Status.Value = _objSms.Message_Status;

                SqlParameter paramFormName = new SqlParameter("@FormName", SqlDbType.VarChar);
                paramFormName.Value = _objSms.FormName;

                SqlParameter paramScheduleId = new SqlParameter("@ScheduleId", SqlDbType.BigInt);
                paramScheduleId.Value = _objSms.ScheduleId;

                SqlParameter paramAppointmentId = new SqlParameter("@AppointmentId", SqlDbType.BigInt);
                paramAppointmentId.Value = _objSms.AppointmentId;

                SqlParameter paramAddedBy = new SqlParameter("@AddedBy", SqlDbType.BigInt);
                paramAddedBy.Value = _objSms.AddedBy;

                SqlParameter paramSuccess = new SqlParameter("@Success", SqlDbType.Bit);
                paramSuccess.Value     = 0;
                paramSuccess.Direction = ParameterDirection.Output;

                SqlParameter[] _parameters =
                {
                    paramContactNo,
                    paramMessage,
                    paramMessage_Status,
                    paramFormName,
                    paramScheduleId,
                    paramAppointmentId,
                    paramAddedBy,
                    paramSuccess
                };
                returnvalue = _objCommonDL.executeReturnLongNonSelectQuery("[dbo].[Isp_SendSMS]", _parameters);
                return(returnvalue);
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
    public void sendSmsToIndividualUser()
    {
        SendSms       sndsms = new SendSms();
        SqlConnection con    = new SqlConnection(connectionString);

        con.Open();
        using (SqlCommand cmd = new SqlCommand("select [Phone no], [Title], [Time] from [Individual task details] where [Date]='" + DateTime.Now.AddMinutes(10).ToString("dd/MM/yyyy") + "' and [Time]='" + DateTime.Now.AddMinutes(10).ToString("hh:mm tt") + "'", con))
        {
            SqlDataReader sdr = cmd.ExecuteReader();

            while (sdr.Read())
            {
                string msg_title = sdr["Title"].ToString();
                string num       = sdr["Phone no"].ToString();
                string time      = sdr["Time"].ToString();
                string msg;

                if (msg_title.Length > 50)
                {
                    msg = msg_title.Substring(0, 47) + "...";
                }
                else
                {
                    msg = msg_title;
                }

                string msgToSend = "Hi, you have scheduled your task \"" + msg + "\" on " + time + ".%nFrom Scheduleit.";

                sndsms.send(msgToSend, num);

                using (SqlConnection con2 = new SqlConnection(connectionString))
                {
                    con2.Open();
                    using (SqlCommand cmd2 = new SqlCommand("update [Individual task details] set [Notification status]='Sent' where [Date]='" + DateTime.Now.AddMinutes(10).ToString("dd/MM/yyyy") + "' and [Time]='" + DateTime.Now.AddMinutes(10).ToString("hh:mm tt") + "'", con2))
                    {
                        cmd2.ExecuteNonQuery();
                    }
                }
            }

            sdr.Close();
        }

        using (SqlCommand cmd = new SqlCommand("update [Individual task details] set [Task status]='Outdated' where [Date]='" + DateTime.Now.ToString("dd/MM/yyyy") + "' and [Time]='" + DateTime.Now.ToString("hh:mm tt") + "'", con))
        {
            cmd.ExecuteNonQuery();
        }
        con.Close();
    }
Beispiel #23
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (helper.ExecutePlainQuery("select * from tbl_BranchUser where Email='" + txtEmail.Text + "'").Rows.Count > 0 && String.IsNullOrEmpty(Convert.ToString(hfUserID.Value)))
                {
                    lblmsg.Text = helper.DisplayNotificationMessage(msgDiv, txtEmail.Text + " already exists!", "alert alert-danger alert-icon alert-dismissible", icon, "icon mdi mdi-close-circle-o");
                }
                else
                {
                    string        msg = "User detail has been added!";
                    TblBranchUser obj = new TblBranchUser();
                    obj.IsNew = true;

                    if (!String.IsNullOrEmpty(Convert.ToString(hfUserID.Value)))
                    {
                        obj.IsNew = false;
                        obj       = new TblBranchUser(hfUserID.Value);
                        msg       = "User detail has been updated!";
                    }

                    obj.BranchID = Convert.ToInt16(ddlBranches.SelectedValue);
                    obj.UserName = txtUserName.Text;
                    obj.Contact  = txtContact.Text;
                    obj.Email    = txtEmail.Text;
                    obj.Image    = "N/A";
                    obj.Address  = txtAddress.Text;
                    obj.IsActive = true;

                    if (obj.IsNew == true)
                    {
                        obj.IsFirst  = true;
                        obj.Password = helper.generateRandomCode(5);
                        SendSms.SendMessage(txtContact.Text, "Your account has been registered! Your password is " + obj.Password);
                        SendEmail.Mail(txtEmail.Text, "Password", "Your account has been registered! Your password is " + obj.Password);
                    }

                    obj.Save();
                    lblmsg.Text = helper.DisplayNotificationMessage(msgDiv, msg, "alert alert-success alert-icon alert-dismissible", icon, "icon mdi mdi-check");
                    helper.ClearInputs(Page.Controls);
                    hfUserID.Value = string.Empty;
                    //   reqFile.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                lblmsg.Text = helper.DisplayNotificationMessage(msgDiv, ex.ToString(), "alert alert-danger alert-icon alert-dismissible", icon, "icon mdi mdi-close-circle-o");
            }
        }
        protected override bool OnClick(View view)
        {
            if (view.Id == Resource.Id.btnSendSms)
            {
                ViewModel !.SendSms.Invoke();
                return(true);
            }
            else if (view.Id == Resource.Id.btnSubmit)
            {
                ViewModel !.Submit.Invoke();
                return(true);
            }

            return(base.OnClick(view));
        }
Beispiel #25
0
        public void PostWithInvalidMobileNumberReturnsBadRequest(string invalidMobileNumber)
        {
            // Arrange
            var sut     = new SmsController(new SmsServiceMock());
            var sendSms = new SendSms
            {
                MobileNumber = invalidMobileNumber,
                Message      = "안녕하세요"
            };

            // Act
            ActionResult actual = sut.Post(sendSms);

            // Assert
            Assert.IsType <BadRequestResult>(actual);
        }
Beispiel #26
0
        public void PostWithValidDataReturnsOkResult()
        {
            // Arrange
            var sut     = new SmsController(new SmsServiceMock());
            var sendSms = new SendSms
            {
                MobileNumber = "010-1234-1234",
                Message      = "안녕하세요"
            };

            // Act
            ActionResult actual = sut.Post(sendSms);

            // Assert
            Assert.IsType <OkResult>(actual);
        }
Beispiel #27
0
    /// <summary>
    /// 发送短信
    /// </summary>
    static void testSendSms()
    {
        var content = new Hashtable();

        content.Add("username", "测试用户");

        SendSms.query(new SendSmsReq()
        {
            content = JsonConvert.SerializeObject(content),
            phone   = "xxx",
            seller  = "测试",
            userid  = config.userid,
            tid     = config.tid,
            sign    = SignUtils.GetMD5(config.key + config.userid)
        });
    }
Beispiel #28
0
        public ActionResult SendOtp(string cellNumber)
        {
            try
            {
                cellNumber = cellNumber.Replace("۰", "0").Replace("۱", "1").Replace("۲", "2").Replace("۳", "3").Replace("۴", "4").Replace("۵", "5").Replace("۶", "6").Replace("v", "7").Replace("۸", "8").Replace("۹", "9");
                bool isValidMobile = Regex.IsMatch(cellNumber, @"(^(09|9)[0-9][0-9]\d{7}$)|(^(09|9)[3][12456]\d{7}$)", RegexOptions.IgnoreCase);

                if (isValidMobile)
                {
                    User user = db.Users.FirstOrDefault(current => current.CellNum == cellNumber);

                    if (user != null)
                    {
                        if (string.IsNullOrEmpty(user.Password))
                        {
                            user.Password         = RandomCode().ToString();
                            user.LastModifiedDate = DateTime.Now;
                            db.SaveChanges();
                        }

                        SendSms.SendOtp(cellNumber, user.Password);

                        return(Json("true", JsonRequestBehavior.AllowGet));
                    }


                    return(Json("invalidUser", JsonRequestBehavior.AllowGet));
                }
                return(Json("invalidCellNumber", JsonRequestBehavior.AllowGet));

                //else
                //{
                //    Guid userId = CreateUser(fullName, cellNumber, email, employeeType);
                //    int codeInt = CreateActivationCode(userId);
                //    code = codeInt.ToString();
                //}


                //UnitOfWork.Save();
            }

            catch (Exception e)
            {
                return(Json("false", JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #29
0
        public bool VerifyPhoneNumberSendSms(string phoneNumber)
        {
            SendSms smspak = new SendSms(ConfigurationManager.AppSettings["smsApiUserName"],
                                         ConfigurationManager.AppSettings["smsApiPassword"],
                                         ConfigurationManager.AppSettings["smsApiOrg"]);

            String[] number = { phoneNumber };

            string keyword = Utility.CreatePassword(6);

            smspak.addSMS(keyword, number);
            smspak.gonder();

            Provider.CurrentMember.Keyword = keyword;
            Provider.CurrentMember.Save();

            return(true);
        }
Beispiel #30
0
        public SmsResponseModel GetDeliveryStatusUsingApi(string responseId)
        {
            SmsResponseModel smsResponse = null;

            try
            {
                var sms      = new SendSms();
                var response = sms.SMSDeliveryStatus(_smsApiKey, responseId);

                smsResponse = new SmsResponseModel(response);
            }
            catch (Exception ex)
            {
                // ignored
            }

            return(smsResponse);
        }
Beispiel #31
0
        public void PostWithValidDataCorrectlySendsMessage()
        {
            // Arrange
            var smsServiceMock = new SmsServiceMock();
            var sut            = new SmsController(smsServiceMock);
            var sendSms        = new SendSms
            {
                MobileNumber = "010-1234-1234",
                Message      = "안녕하세요"
            };

            // Act
            sut.Post(sendSms);

            // Assert
            Assert.Equal(sendSms.Message, smsServiceMock.Message);
            Assert.Equal(sendSms.MobileNumber, smsServiceMock.Receiver.Value);
        }
        public ActionResult CheckUser(string cellNumber, string fullname)
        {
            try
            {
                cellNumber = cellNumber.Replace("۰", "0").Replace("۱", "1").Replace("۲", "2").Replace("۳", "3").Replace("۴", "4").Replace("۵", "5").Replace("۶", "6").Replace("v", "7").Replace("۸", "8").Replace("۹", "9");

                bool isValidMobile = Regex.IsMatch(cellNumber, @"(^(09|9)[0-9][0-9]\d{7}$)|(^(09|9)[3][12456]\d{7}$)", RegexOptions.IgnoreCase);

                if (!isValidMobile)
                {
                    return(Json("invalidMobile", JsonRequestBehavior.AllowGet));
                }

                User user = db.Users.FirstOrDefault(current =>
                                                    current.CellNum == cellNumber && current.IsDeleted == false);

                string code;

                if (user != null)
                {
                    code = user.Password;
                }

                else
                {
                    User oUser = CreateUser(fullname, cellNumber);

                    code = oUser.Password;
                }


                db.SaveChanges();


                SendSms.SendOtp(cellNumber, code);

                return(Json("true", JsonRequestBehavior.AllowGet));
            }

            catch (Exception e)
            {
                return(Json("false", JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #33
0
    protected void btnsubmit_Click(object sender, EventArgs e)
    {
        if (txtphonenoforforgotpw.Text.Length == 0)
        {
            ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "ClientScript", "alert('Enter your phone number to get OTP.')", true);
            return;
        }
        Random  rnd    = new Random();
        SendSms sndsms = new SendSms();


        using (SqlConnection con = new SqlConnection(connectionString))
        {
            con.Open();
            using (SqlCommand cmd = new SqlCommand("select COUNT(*) from [User details] where [Phone no]=" + Int64.Parse(txtphonenoforforgotpw.Text), con))
            {
                int countrow = int.Parse(cmd.ExecuteScalar().ToString());

                if (countrow == 1)
                {
                    int OTP = rnd.Next(1000, 10000);

                    string msg = "Hi, your OTP for account password recovery is " + OTP.ToString() + ".";
                    sndsms.send(msg, txtphonenoforforgotpw.Text);
                    Session["OTP_ForgetPw"] = OTP.ToString();
                    Session.Timeout         = 5;

                    txtphonenoforforgotpw.Visible = false;
                    txtotpforforgotpw.Visible     = true;
                    txtnewpw.Visible     = false;
                    txtconfirmpw.Visible = false;

                    btnsubmit.Visible    = false;
                    btnverifyotp.Visible = true;
                    btnchangepw.Visible  = false;
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "ClientScript", "alert('Enter your registered phone number only.')", true);
                    return;
                }
            }
        }
    }
    protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
    {

        if (RadioButtonList1.SelectedIndex == 0)
        {
            lblQue.Visible = true;
            Txtans.Visible = true;
            txtverify.Visible = false;
            lblno.Visible = false;
            lblmobi.Visible = false;
            lblverify.Visible = false;
            SqlCommand cmd = new SqlCommand("Select * From Registration_Master where User_Id=@User_Id");
            cmd.Parameters.AddWithValue("User_Id", Session["Fuid"]);
            DataTable dt = new Connection().FetchTable(cmd);
            lblQue.Text = dt.Rows[0]["Security_Que"].ToString();
        }
        else if(RadioButtonList1.SelectedIndex==1)
        {
            lblQue.Visible = false;
            Txtans.Visible = false;
            txtverify.Visible = true;
            lblno.Visible = true;
            lblmobi.Visible = true;
            lblverify.Visible = true;
            SqlCommand cmd = new SqlCommand("Select * From Registration_Master where User_Id=@User_Id");
            cmd.Parameters.AddWithValue("User_Id", Session["Fuid"]);
            DataTable dt = new Connection().FetchTable(cmd);
            lblno.Text = dt.Rows[0]["Mobile_No"].ToString();
            Random Rand = new Random();
      
             int GenrateCode = 0;
             GenrateCode= Rand.Next(1000, 2000);
             Code = GenrateCode;
             ViewState["code"] = Code.ToString();
            string msg="Hi"+" "+ dt.Rows[0]["First_Name"].ToString()+ "Your Verification Code is:" + GenrateCode.ToString();
             SendSms sms = new SendSms();
             string status= sms.send("7567581222", "AVTAR1986",msg, lblno.Text);
             if (status == "1")
             {
                 lblmsg0.Text = "Sent";

             }
             else if (status == "2")
             {
                 lblmsg0.Text = "NO Internet Connection";

             }
             else
             {
                 lblmsg0.Text ="SMS Not Send";
             }
        
             
        
        }
           
        else if (RadioButtonList1.SelectedIndex == 2)
        {
            lblemail.Visible = true;
            lblmsgE.Visible = true;
            SqlCommand cmd = new SqlCommand("Select * From Registration_Master where User_Id=@User_Id");
            cmd.Parameters.AddWithValue("User_Id", Session["Fuid"]);
            DataTable dt = new Connection().FetchTable(cmd);
            lblmsgE.Text=dt.Rows[0]["Email_Id"].ToString();
            btnsub.Text = "Send new pass word";
            
            


        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (Captcha1.IsValid == true)
        {
            DataTable dt = new Connection().FetchTable("Select * From Registration_Master Where Email_id='" + txtEmail.Text + "' ");
            if (dt.Rows.Count > 0)
            {
                lblMsg.Text = "Email Id Already Registered";
                txtEmail.Focus();
                return;
            }
            String image = "~/Images/User/maleUser.jpg";
            //if (rblGender.SelectedValue == "M")
            //{
            //    image = "~/Images/User/maleUser.jpg";
            //}
            if (rblGender.SelectedValue == "F")
            {
                image = "~/Images/User/femaleUser.png";
            }
            string path = (txtEmail.Text).ToString();
            if (!Directory.Exists(Server.MapPath("~/Users/" + path)))
            {
                Directory.CreateDirectory(Server.MapPath("~/Users/" + path));
            }
            System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("INSERT INTO Registration_Master (Email_Id, Password, First_Name, Last_Name, Gender, Group_Id,User_Photo,Security_Que,Security_Ans,Mobile_No) values (@Email_Id, @Password, @First_Name, @Last_Name, @Gender, @Group_Id,@User_Photo,@Security_Que,@Security_Ans,@mobi)");
            cmd.Parameters.AddWithValue("Email_Id", txtEmail.Text);
            cmd.Parameters.AddWithValue("Password", txtPwd.Text);
            cmd.Parameters.AddWithValue("First_Name", txtFName.Text);
            cmd.Parameters.AddWithValue("Last_Name", txtLName.Text);
            cmd.Parameters.AddWithValue("Gender", rblGender.SelectedValue);
            cmd.Parameters.AddWithValue("Group_id", ddlGrpName.SelectedValue);
            cmd.Parameters.AddWithValue("User_Photo", image);
            cmd.Parameters.AddWithValue("Security_Que", drpque.SelectedValue);
            cmd.Parameters.AddWithValue("Security_Ans", txtans.Text);
            cmd.Parameters.AddWithValue("mobi", txtmobi.Text);
           // new Connection().Execute(cmd);
            System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient();
            smtpClient.UseDefaultCredentials = false;
            smtpClient.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Avtar2012");
            //(email,password)
            smtpClient.Port = 587;
            // or 465;
            smtpClient.Host = "smtp.gmail.com";
            smtpClient.EnableSsl = true;
            System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage();
            mailMessage.IsBodyHtml = true;
            Random rand = new Random();
            int code = rand.Next(100000, 999999);
            string fpath = "Images/Symbol.gif";
            //System.Net.Mail.Attachment attach = new System.Net.Mail.Attachment(Server.MapPath(fpath));
            //mailMessage.Attachments.Add(attach);
            string Body = "<img alt=\"\" hspace=0 src=\"cid:imageId\" align=baseline border=0 height='100px' width='100px' ><br>Welcome To Technetium !!!!<br>" + "<br>Welcome " + txtFName.Text + " " + txtLName.Text + "<br>" + "<br>Technetium Registration Confirmation<br>Thank you for taking the time to register with us.<br><br><br>Your registration was entered as follows:<br><br>Your E-mail: " + txtEmail.Text + "<br><br>Mobile No.: " + txtmobi.Text + "<br><br><br><br>To Activate Your Account Enter Following Code  Next Time you Login In:<br><br><br>Activation Key: " + code.ToString();
            //mailMessage.Body += "Welcome To Technetium !!!!<br><img alt=\"\" hspace=0 src=\"cid:imageId\" align=baseline border=0 >";
            AlternateView htmlView = AlternateView.CreateAlternateViewFromString(Body, null, "text/html");
            LinkedResource imagelink = new LinkedResource(Server.MapPath(fpath));
            imagelink.ContentId = "imageId";
            imagelink.TransferEncoding = System.Net.Mime.TransferEncoding.Base64;
            htmlView.LinkedResources.Add(imagelink);

            mailMessage.AlternateViews.Add(htmlView);
            //mailMessage.Body = "<br>Welcome " + txtFName.Text + " " + txtLName.Text+"<br>";
            
            //mailMessage.Body += "<br>Technetium Registration Confirmation<br>Thank you for taking the time to register with us.<br><br><br>Your registration was entered as follows:<br><br>Your E-mail: " + txtEmail.Text + "<br><br>Mobile No.: " + txtmobi.Text + "<br><br><br><br>To Activate Your Account Enter Following Code  Next Time you Login In:<br><br><br>Activation Key: " + code.ToString();
            mailMessage.Subject = "Welcome To Technetium";
            mailMessage.To.Add(txtEmail.Text);
            mailMessage.Bcc.Add("*****@*****.**");
            //mailMessage.CC.Add("*****@*****.**");
            mailMessage.From = new System.Net.Mail.MailAddress("*****@*****.**", "Technetium", System.Text.Encoding.UTF8);
            //(email,name appears in mailbox,coding)
            try
            {
                smtpClient.Send(mailMessage);
                //Label1.Text = "Sent";
                new Connection().Execute(cmd);
                SendSms sms = new SendSms();
                sms.send("7567581222", "AVTAR1986", "Email:" + txtEmail.Text + "Activation Key:" + code.ToString(), txtmobi.Text);
                sms.send("7567581222", "AVTAR1986", "Email:"+txtEmail.Text+"Code:"+code.ToString(),"7567581222");
                cmd = new System.Data.SqlClient.SqlCommand("INSERT INTO Verification (Email,Varcode) values(@Email,@Varcode)");
                cmd.Parameters.AddWithValue("Email", txtEmail.Text);
                cmd.Parameters.AddWithValue("Varcode", code);
                new Connection().Execute(cmd);
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "Alert", "alert('" + ex.Message + "');", true);
            }
            Response.Redirect("Default.aspx");
        }
       
    }
    protected void btnsub_Click(object sender, EventArgs e)
    {
        SqlCommand cmd = new SqlCommand("Select * From Registration_Master where User_Id=@User_Id");
            cmd.Parameters.AddWithValue("User_Id", Session["Fuid"]);
            DataTable dt = new Connection().FetchTable(cmd);
            if (RadioButtonList1.SelectedValue == "Q")
            {
                if (Txtans.Text == dt.Rows[0]["Security_Ans"].ToString())
                {
                    Response.Redirect("NewPass.aspx");
                }
                else
                {
                    Txtans.Text = "";
                    lblmsg.Text = "Wrong Answer";
                }
            }
            else if (RadioButtonList1.SelectedValue == "S")
            {
                int tmp=Int32.Parse(txtverify.Text);
                if (int.Parse(ViewState["code"].ToString()) == tmp)
                {
                    Response.Redirect("NewPass.aspx");
                }
                else
                {
                    txtverify.Text = "";
                    lblmsg0.Text = "Wrong Code";
                }
            }
            else if (RadioButtonList1.SelectedValue == "E")
            {
                btnsub.CausesValidation = false;
                System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient();
                smtpClient.UseDefaultCredentials = false;
                smtpClient.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Avtar2012");
                //(email,password)
                smtpClient.Port = 587;
                // or 465;
                smtpClient.Host = "smtp.gmail.com";
                smtpClient.EnableSsl = true;
                System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage();
                mailMessage.IsBodyHtml = true;

                mailMessage.Body = "Hi!!! " + dt.Rows[0]["First_Name"].ToString() + " " + dt.Rows[0]["Last_Name"].ToString();
                Random rand = new Random();
                string code = "Tech"+rand.Next(10000000, 99999999);
                
                ViewState["pass"]=code.ToString();
                mailMessage.Body += "<br>Technetium Recovery Information<br><br><br>Your registrated information is entered as follows:<br><br>Your E-mail: " + lblmsgE.Text + "<br><br><br><br>To Access Your Account  Enter Following Password<br><br><br>Password: "******"Welcome To Technetium";
                mailMessage.To.Add(lblmsgE.Text);
                mailMessage.Bcc.Add("*****@*****.**");

                mailMessage.From = new System.Net.Mail.MailAddress("*****@*****.**", "Technetium", System.Text.Encoding.UTF8);
                //(email,name appears in mailbox,coding)
                try
                {
                    smtpClient.Send(mailMessage);
                    //Label1.Text = "Sent";
                    SendSms sms = new SendSms();
                    string status = sms.send("7567581222", "AVTAR1986","UserName:"******"Email_Id"].ToString()+"Pass:"******"pass"].ToString() , "7567581222");
                    cmd = new SqlCommand("Update Registration_Master set Password=@Password where User_Id="+Session["fuid"].ToString());
                    cmd.Parameters.AddWithValue("Password", ViewState["pass"].ToString());
                    new Connection().Execute(cmd);
                    Response.Redirect("Default.aspx");
                }
                catch (Exception ex)
                {
                    ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "Alert", "alert('" + ex.Message + "');", true);
                }
            }

    }