/// <summary> /// ใช้กรณี มีการ approve ผ่านช่องทางอื่นที่ไม่ใช่ sms แต่ว่าเพิ่งได้รับ message แล้ว approve มาจะทำให้ work flow เกิด error ไม่สามารถ approve ได้ /// </summary> /// <param name="Refno"></param> /// <param name="mobilePhone"></param> /// <param name="NoitfySMS"></param> public void SendSMS09(string Message, string Refno, string mobilePhone, bool NoitfySMS) { try { if (ParameterServices.EnableSMS) { SMSDTO smsDto = new SMSDTO(); smsDto.From = SS.DB.Query.ParameterServices.SMSPhoneNumber; string Mobile = "66" + mobilePhone.ToString().Remove(0, 1); smsDto.To = Mobile; smsDto.UseProxy = true; try { smsDto.Content = System.Web.HttpUtility.HtmlEncode(string.Format(ParameterServices.NotifyDocStatusChanged, Refno)); } catch (Exception ex) { string error = ex.Message; smsDto.Content = System.Web.HttpUtility.HtmlEncode(string.Format("This refno. {0} has been changed on work flow event.", Refno)); } this.sendSMSStatus = SMSService.Send(smsDto, NoitfySMS); } } catch (Exception ex) { Utilities.WriteLogs("To approve Failed : " + ex.Message, "smslog", "Logs", "txt"); } }
/// <summary> /// กรณี login failed ทำให้ไม่สามารถ approve ได้ /// </summary> /// <param name="Refno"></param> /// <param name="UserID"></param> /// <param name="NotifySMS"></param> public void SendSMS06(string Refno, long UserID, bool NotifySMS) { try { if (ParameterServices.EnableSMS) { SuUser sendToUser = QueryProvider.SuUserQuery.FindByIdentity(UserID); if (sendToUser.SMSApproveOrReject) { SMSDTO smsDto = new SMSDTO(); smsDto.From = SS.DB.Query.ParameterServices.SMSPhoneNumber; string Mobile = "66" + sendToUser.MobilePhoneNo.ToString().Remove(0, 1); smsDto.To = Mobile; smsDto.UseProxy = true; try { smsDto.Content = System.Web.HttpUtility.HtmlEncode(string.Format(ParameterServices.NotifyLoginFailed, Refno)); } catch (Exception ex) { string error = ex.Message; smsDto.Content = System.Web.HttpUtility.HtmlEncode(string.Format("To approve Ref.{0} via sms was login failed, Please contact admin. Send by: SCG Account", Refno)); } this.sendSMSStatus = SMSService.Send(smsDto, NotifySMS); } } } catch (Exception ex) { Utilities.WriteLogs("To approve Failed : " + ex.Message, "smslog", "Logs", "txt"); } }
/// <summary> /// กรณี ส่งมา approve ผิด format login ไม่ได้ /// </summary> /// <param name="Refno"></param> /// <param name="mobilePhone"></param> /// <param name="NoitfySMS"></param> public void SendSMS07(string Refno, string mobilePhone, bool NoitfySMS) { try { if (ParameterServices.EnableSMS) { SMSDTO smsDto = new SMSDTO(); smsDto.From = SS.DB.Query.ParameterServices.SMSPhoneNumber; string Mobile = "66" + mobilePhone.ToString().Remove(0, 1); smsDto.To = Mobile; smsDto.UseProxy = true; try { smsDto.Content = System.Web.HttpUtility.HtmlEncode(string.Format(ParameterServices.NotifyApproveWrongFormat, Refno)); } catch (Exception ex) { string error = ex.Message; smsDto.Content = System.Web.HttpUtility.HtmlEncode(string.Format("To approve Refno. {0} format error, Please approve again. Try send XXXXXXY=Approve or XXXXXXN=Reject", Refno)); } this.sendSMSStatus = SMSService.Send(smsDto, NoitfySMS); } } catch (Exception ex) { Utilities.WriteLogs("To approve Failed : " + ex.Message, "smslog", "Logs", "txt"); } }
public void SendSMS03(long workFlowID, string RequestID, IList <long> ReciverList) { try { if (ParameterServices.EnableSMS) { Document document = WorkFlowQueryProvider.WorkFlowQuery.GetDocumentByWorkFlowID(workFlowID); SCGDocument scgDocument = ScgeAccountingQueryProvider.SCGDocumentQuery.FindByIdentity(document.DocumentID); FnAutoPayment autoPayment = ScgeAccountingQueryProvider.FnAutoPaymentQuery.GetFnAutoPaymentByDocumentID(document.DocumentID); foreach (long userID in ReciverList) { SuUser sendToUser = QueryProvider.SuUserQuery.FindByIdentity(userID); if (sendToUser.SMSReadyToReceive) { string ToPhoneNo = sendToUser.MobilePhoneNo.ToString(); SMSDTO smsDto = new SMSDTO(); string Mobile = "66" + ToPhoneNo.ToString().Remove(0, 1); smsDto.To = Mobile; smsDto.PaymentDate = autoPayment.PaymentDate.Value; smsDto.Amount = autoPayment.Amount.ToString(); smsDto.Requestor = RequestID; smsDto.DocumentNo = scgDocument.DocumentNo; smsDto.UseProxy = true; smsDto.Content = BuildContentBody(smsDto, SMSContenFormat.SMS03, SMSBusinessCase.Cheque); this.sendSMSStatus = SMSService.Send(smsDto); } } } } catch (Exception ex) { Utilities.WriteLogs("SendSMS03 : ==> " + ex.Message, "smslog", "Logs", "txt"); } }
public void SendSMS05(string RefNo, long UserID, bool NotifySMS, string ApproveFlag) { try { if (ParameterServices.EnableSMS) { SuUser sendToUser = QueryProvider.SuUserQuery.FindByIdentity(UserID); if (sendToUser.SMSApproveOrReject) { SMSDTO smsDto = new SMSDTO(); smsDto.From = SS.DB.Query.ParameterServices.SMSPhoneNumber; string Mobile = "66" + sendToUser.MobilePhoneNo.ToString().Remove(0, 1); smsDto.To = Mobile; smsDto.UseProxy = true; try { smsDto.Content = System.Web.HttpUtility.HtmlEncode(string.Format(ParameterServices.NotifyApprovedCompleted, RefNo, ApproveFlag.ToLower())); } catch (Exception ex) { string error = ex.Message; smsDto.Content = System.Web.HttpUtility.HtmlEncode("To approve Ref." + RefNo + " was " + ApproveFlag.ToLower() + " completed"); } this.sendSMSStatus = SMSService.Send(smsDto, NotifySMS); } } } catch (Exception ex) { Utilities.WriteLogs("To approve Failed : " + ex.Message, "smslog", "Logs", "txt"); } }
public async Task <dynamic> Register(RegistrationRequest model) { HttpResponseMessage responce = Utils.CheckModel(model, Request); if (!responce.IsSuccessStatusCode) { return(responce); } var user = new ApplicationUser() { PhoneNumber = model.phone, FirstName = model.firstName, LastName = model.lastName, OTPSecret = Base.LoginUtils.generateSalt() }; //create user user.UserName = Guid.NewGuid().ToString(); //give the USername a value, for soem reason IdentityResult result = new IdentityResult(); try { // Your code... // Could also be before try if you know the exception occurs in SaveChanges result = await UserManager.CreateAsync(user, model.Password); } catch (Exception original) { Exception innermost = original; while (innermost.InnerException != null) { innermost = innermost.InnerException; } if (innermost.GetType() == typeof(System.Data.SqlClient.SqlException)) // true) { var sqlException = (System.Data.SqlClient.SqlException)innermost; if (sqlException.Number == 2601) { return(Request.CreateResponse(HttpStatusCode.BadRequest, ErrorResponse.PhoneTaken)); } } return(innermost); } if (result.Succeeded) { string otp = Base.LoginUtils.GenerateOTP(user); await SMSService.SendMessage(model.phone.ToString(), "Welcome to Hive, your code is " + otp + " use it to confirm your phone number within 5 min"); return(responce); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, ErrorResponse.SomethingHappened)); } }
public AccountController() { serviceUser = new UserService(db); serviceAccount = new AccountService(db, redisC); serviceSMS = new SMSService(redisC); serviceSecuritye = new SecurityeService(redisC); }
/// <summary> /// Will delete a ralationship between you and another user, as long as you are not the one that was blocked /// </summary> /// <param name="id">ID of the RELATIONSHIP not the user</param> /// <returns>Returns OK if done, and ErrorResponce if there is an error</returns> public async Task <dynamic> Delete([FromUri] long id) { var UserId = long.Parse(User.Identity.GetUserId()); var contactDb = await db.Contacts.FirstOrDefaultAsync( p => (p.Person1Id == UserId && p.Id == id) || (p.Id == id && p.Person2Id == UserId)); if (contactDb == null) { return(Request.CreateResponse(HttpStatusCode.BadRequest, ErrorResponse.DoesntExist)); } var contact = contactDb.ToContact(UserId); if (contact.state == ContactDb.StateBlockedP1) { return(Request.CreateResponse(HttpStatusCode.BadRequest, ErrorResponse.IllegalChanges)); } db.Contacts.Remove(contactDb); await db.SaveChangesAsync(); var parties = await db.Users.Where(p => p.Id == contactDb.Person1Id || p.Id == contactDb.Person2Id).ToArrayAsync(); long phone = parties.First(p => p.Id != UserId).PhoneNumber; string actorName = parties.First(p => p.Id == UserId).FirstName + " " + parties.First(p => p.Id == UserId).LastName; string SmsMesage = "Hive: " + actorName + " has deleted you!"; SMSService.SendMessage(phone.ToString(), SmsMesage); //We don;t want to await an SMS, really return(Ok()); }
public async Task <ActionResult <Order> > Post(Order order) { Random random = new Random(); order.OrderCode = random.Next(999999); order.OrderPlacementDate = DateTime.UtcNow.AddHours(5); order.OrderDeliveryDate = DateTime.UtcNow.AddHours(5); _db.Orders.Update(order); await _db.SaveChangesAsync(); foreach (var item in order.OrderItems) { Product product = await _db.Products.Where(x => x.Id == item.ProductId).FirstOrDefaultAsync(); product.Quantity = product.Quantity - item.Quantity; _db.SaveChangesAsync(); } var User = await _db.Users.Where(x => x.Id == order.UserId).FirstOrDefaultAsync(); EmailService email = new EmailService(_db); SMSService sms = new SMSService(_db); sms.sendOrderCodeSMS(order.OrderCode, User.Contact_Number); email.sendOrderCode(order.OrderCode, User.Email_Address); var Riders = await _db.Users.Where(x => x.RoleId == 4 && x.IsDisabled == false && x.IsVerified == true).ToListAsync(); foreach (var rider in Riders) { var Message = "New Order is placed. login to kuicksave for details"; sms.sendMessage(Message, rider.Contact_Number); } return(CreatedAtAction(nameof(GetSingle), new { id = order.Id }, order)); }
/// <summary> /// 测试用手机 /// </summary> /// <param name="mobile"></param> public ContentResult SendSMS(string mobile, string orderId) { //var result = SMSService.SendSMSPreOrderSendProduct(mobile, orderId); var result = SMSService.SendSMSPreOrderCreated(mobile, ""); return(Content("result=" + result)); }
/// <summary> /// ใช้กรณี มีการ approve ผ่านเบอร์คนอื่นที่ไม่ใช่ เบอร์ที่รับ message /// </summary> /// <param name="Refno"></param> /// <param name="mobilePhone"></param> /// <param name="NoitfySMS"></param> public void SendSMS10(string Refno, string mobilePhone, bool NoitfySMS) { try { if (ParameterServices.EnableSMS) { SMSDTO smsDto = new SMSDTO(); smsDto.From = SS.DB.Query.ParameterServices.SMSPhoneNumber; string Mobile = "66" + mobilePhone.ToString().Remove(0, 1); smsDto.To = Mobile; smsDto.UseProxy = true; try { smsDto.Content = System.Web.HttpUtility.HtmlEncode(string.Format(ParameterServices.NotifyWrongMobileNumber, Refno)); } catch (Exception ex) { string error = ex.Message; smsDto.Content = System.Web.HttpUtility.HtmlEncode(string.Format("Can use mobile number's message box owner for approve/reject refno.{0} only", Refno)); } this.sendSMSStatus = SMSService.Send(smsDto, NoitfySMS); } } catch (Exception ex) { Utilities.WriteLogs("To approve Failed : " + ex.Message, "smslog", "Logs", "txt"); } }
public async Task <ActionResult> Register(RegisterViewModel model) { if (!SMSService.IsSistemaEmProducao()) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); return(RedirectToAction("Index", "Home")); } AddErrors(result); } } // If we got this far, something failed, redisplay form return(View(model)); }
private static void SendSMS(DSModel db, SMSService sms, NotificationModel notice) { try { string senderNumber = GLOB.Settings.Get<string>(16); string[] managementNumbers = GLOB.Settings.Get<string>(17).Split(';'); List<string> numbersToSend = new List<string>(); if (notice.ReminderType == (uint)ReminderType.Driver || notice.ReminderType == (uint)ReminderType.MVR) numbersToSend.Add("1" + notice.CellPhone.Replace("-", string.Empty).Replace(" ", string.Empty).Trim()); if (notice.ReminderType == (uint)ReminderType.Management || notice.ReminderType == (uint)ReminderType.MVR) numbersToSend.AddRange(managementNumbers); bool status = false; foreach (string number in numbersToSend) { try { if (sms.SendSMS(senderNumber, number, notice.Message)) status = true; } catch { } } NotificationRepository.UpdateNotificationStatus(db, notice, status); } catch { } }
public async Task OnPaymentSuccessul(BookReservation reseravtion, Transaction transaction) { using (var db = new BookingContext()) { var users = await db.Users.Where(x => !x.LockedOut && x.Claims.FirstOrDefault().Value == UserRoles.Admin).Select(x => new { x.Phone, x.Email, x.PhoneConfirmed, x.EmailConfirmed }).ToListAsync(); var phoneTargets = users.Where(x => x.PhoneConfirmed); if (phoneTargets.Count() > 0) { await SMSService.SendAsync(new SMS.SendSMSOptions() { Destinations = phoneTargets.Select(x => x.Phone).ToArray(), Message = $"Payment of {transaction.IdealAmount} GHS has been successfully made for the reservation #{reseravtion.ReferenceNo}." }); } var emailTargets = users.Where(x => x.EmailConfirmed); if (emailTargets.Count() > 0) { await EmailService.SendAsync(new Email.SendMailOptions() { Destinations = emailTargets.Select(x => x.Email).ToArray(), Subject = "Payment Received", IsHtml = true, Message = $"<h3>Payment Received</h3><br/><p>Payment of <b>{transaction.IdealAmount} GHS</b></p> has been received for a new reservation #{reseravtion.ReferenceNo}", }); } } // Broadcast signal for payment GlobalHost.ConnectionManager.GetHubContext <CoreHub>().Clients.All.OnReservationPaid(reseravtion.Id); }
private static void SendSMS(DSModel db, SMSService sms, NotificationModel notice) { try { string senderNumber = GLOB.Settings.Get <string>(16); string[] managementNumbers = GLOB.Settings.Get <string>(17).Split(';'); List <string> numbersToSend = new List <string>(); if (notice.ReminderType == (uint)ReminderType.Driver || notice.ReminderType == (uint)ReminderType.MVR) { numbersToSend.Add("1" + notice.CellPhone.Replace("-", string.Empty).Replace(" ", string.Empty).Trim()); } if (notice.ReminderType == (uint)ReminderType.Management || notice.ReminderType == (uint)ReminderType.MVR) { numbersToSend.AddRange(managementNumbers); } bool status = false; foreach (string number in numbersToSend) { try { if (sms.SendSMS(senderNumber, number, notice.Message)) { status = true; } } catch { } } NotificationRepository.UpdateNotificationStatus(db, notice, status); } catch { } }
protected void updateUserProfile(object sender, EventArgs e) { SqlConnection dbConnection = new SqlConnection("Data Source=itksqlexp8;Integrated Security=true"); try { dbConnection.Open(); dbConnection.ChangeDatabase("nasa_SilentAuction_v1"); string name = Session["user_id"] as string; str = "Update users set firstName='" + fname.Text + "', lastName='" + lname.Text + "', addressLine1='" + addressLine1.Text + "', addressLine2='" + addressLine2.Text + "', city='" + city.Text + "', stateName='" + state.Text + "', phoneHome='" + phoneNumber.Text + "', phncarrier='" + networkProvider.SelectedValue + "', email='" + email.Text + "', password='******' WHERE userID='" + userid1.Text + "'"; SqlCommand sqlCommand = new SqlCommand(str, dbConnection); var x = sqlCommand.ExecuteNonQuery(); string message = "Bingo! your profile has been Updated. For confirmation we have sent you an email, Happy Bidding :)"; textMessage = new SMSService(networkProvider.Text, phoneNumber.Text, message); textMessage.SendTextMessage(textMessage); UpdateReply.Text = "Data Updated Successfully, Please check your inbox :)"; } catch (SqlException exception) { Response.Write("<p>Error code " + exception.Number + ": " + exception.Message + "</p>"); } }
public async Task <IActionResult> AddCheckListPointComment(FMSEmergencyCheckCommentVM comment) { try { var currentUser = (from u in dbContext.Users where u.Email == User.Identity.Name select u).FirstOrDefault(); FMSEmergencyCheckComment newComment = new() { Id = Guid.NewGuid(), FMSEmergencyCheckId = comment.FMSEmergencyCheckId, FMSEmergencyId = comment.FMSEmergencyId, Comment = comment.Comment, FMSUserId = new Guid((from u in dbContext.Users where u.Email == User.Identity.Name select u.Id).SingleOrDefault()), FMSVehicleId = comment.FMSVehicleId, VehicleNumber = comment.VehicleNumber, LastUpdated = DateTime.Now, Mentions = comment.Mentions }; await dbContext.FMSEmergencyCheckComments.AddAsync(newComment); await dbContext.SaveChangesAsync(); FMSEmergencyCheck check = await(from a in dbContext.FMSEmergencyCheckList where a.Id == comment.FMSEmergencyCheckId select a).SingleOrDefaultAsync(); check.CommentCount = await(from c in dbContext.FMSEmergencyCheckComments where c.FMSEmergencyCheckId == comment.FMSEmergencyCheckId select c).CountAsync(); check.MaintenanceStatus = CheckMaintenanceStatus.InProgress; await dbContext.SaveChangesAsync(); if (!string.IsNullOrEmpty(comment.Mentions)) { string[] mentions = comment.Mentions.Split(','); foreach (var mention in mentions) { ApplicationUser user = (from u in dbContext.Users where u.Id == mention select u).FirstOrDefault(); await hubContext.Clients.All.SendAsync("ReceiveMessage", user.Email, $"Notification for Vehicle Number {check.VehicleNumber}", $"{currentUser.Name} mentioned you in a comment under emergency check list point {check.Description}"); await SMSService.SendSMS($"Notification for Vehicle Number {check.VehicleNumber}: {currentUser.Name} mentioned you in a comment under emergency check list point {check.Description}", "03035650720"); SMSService.SendMail($"Notification for Vehicle Number {check.VehicleNumber}", $"{currentUser.Name} mentioned you in a comment under emergency check list point {check.Description}", "*****@*****.**"); } } return(Ok()); } catch (Exception ex) { return(BadRequest(ex.ToString())); } }
public static ParamContainer CreateParamContainer(ILogger loggerController, IActionExecuter actionExecuter) { ILogReader logReader = Logger.GetLogReader(); IAppSettingService appSettingService = AppSettingService.Instance; ParamContainer paramContainer = new ParamContainer(); IDBService dbService = ApplicationConfig.DependencyResolver.GetInstance <IDBService>(); IPingService pingService = ApplicationConfig.DependencyResolver.GetInstance <IPingService>(); IViewEngine viewEngine = ApplicationConfig.DependencyResolver.GetInstance <IViewEngine>(); IEncryption encryption = ApplicationConfig.DependencyResolver.GetInstance <IEncryption>(); IKeyValueStorage keyValueStorage = ApplicationConfig.DependencyResolver.GetInstance <IKeyValueStorage>(); ISMSService smsService = new SMSService(loggerController, dbService, actionExecuter, viewEngine, paramContainer); IEmailService emailService = new EmailService(loggerController, dbService, actionExecuter, viewEngine, paramContainer); IOTPService otpService = new OTPService(loggerController, dbService, smsService, emailService, appSettingService); paramContainer.AddKey(CommonConst.CommonValue.PARAM_DBPROXY, () => { return(dbService); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_LOGGER, () => { return(loggerController); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_ACTIONEXECUTER, () => { return(actionExecuter); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_PING_SERVICE, () => { return(pingService); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_PING_SERVICE, () => { return(pingService); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_APP_SETTING, () => { return(appSettingService); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_VIEW_ENGINE, () => { return(viewEngine); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_OTP_SERVICE, () => { return(otpService); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_SMS_SERVICE, () => { return(smsService); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_EMAIL_SERVICE, () => { return(emailService); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_ENCRYPTION_SERVICE, () => { return(encryption); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_KEY_VALUE_STORAGE, () => { return(keyValueStorage); }); paramContainer.AddKey(CommonConst.CommonValue.PARAM_HTTP_CLIENT, () => { return(new HttpRestClient()); }); return(paramContainer); }
private async void SendButton_Click(object sender, RoutedEventArgs e) { createSMS(); if (SMS != null) { int result = SMSManager.Instance.SendASMS(SMS.PHONE_NUMBER, SMS.CONTENT); if (result == 1) { await MainWindow.Instance.ShowMessageAsync(Messages.TTL_MSG, "Sms has been sent", MessageDialogStyle.Affirmative); SMS.SENDING_STATUS = true; SMS.SEND_DATE_TIME = System.DateTime.Now; SMSService.InsertSMS(SMS); SMS = null; } else { await MainWindow.Instance.ShowMessageAsync(Messages.TTL_MSG, "Sms sending failed", MessageDialogStyle.Affirmative); SMS.SENDING_STATUS = false; SMS.SEND_DATE_TIME = System.DateTime.Now; SMSService.InsertSMS(SMS); } } else { await MainWindow.Instance.ShowMessageAsync(Messages.TTL_MSG, "Please Select a Customer!", MessageDialogStyle.Affirmative); } }
public void GetIMSIInfo_test_with_null_result() { MockDbContext.Setup(s => s.Single <IMSIInfo>(It.IsAny <Expression <Func <IMSIInfo, bool> > >())); var result = SMSService.GetMobile(IMSI_EXAMPLE); Assert.Null(result); }
/// <summary> /// 注册 /// </summary> /// <param name="phone"></param> /// <param name="password"></param> /// <param name="Gender"></param> /// <returns></returns> public ResultModel <MemberModel> Register(string phone, string password, bool?gender, string code) { var result = new ResultModel <MemberModel>(); var verificationCode = new SMSService().VerificationCode(redisContext, phone, code); if (!verificationCode.Success) { result.Message = verificationCode.Message; return(result); } var member = new Member { Gender = gender, Password = password, PhoneNumber = phone }; dbContext.Member.Add(member); if (!dbContext.Save()) { result.Message = "注册失败"; return(result); } result.Data = member.Translate <Member, MemberModel>(); //发布用户注册消息 rabbitMQService.Publish <RegisterMemberEvent>(new RegisterMemberEvent { MemberId = member.Id, PhoneNumber = member.PhoneNumber }, "RegisterMemberEvent"); return(result); }
public ActionResult SMSCode(string account, string t) { try { if (!SSOClient.Validate(account, out SysUser user)) { return(Json(new { Code = 1, Msg = "帐号不存在,请重新输入!" })); } string code = VerifyHelper.CreateNumber(4); SMSService.Send(user.Mobile, code); dbContext.SysSmsCode.Add(new SysSmsCode() { Id = Guid.NewGuid(), Mobile = user.Mobile, CreateTime = DateTime.Now, OverTime = DateTime.Now.AddMinutes(3), IsVerify = 0, SmsCode = code, SmsSign = t }); dbContext.SaveChanges(); return(Json(new { Code = 0, Msg = "发送成功!" })); } catch (Exception ex) { LogHelper.SaveLog(ex); return(Json(new { Code = 1, Msg = "服务器异常,请联系管理员!" })); } }
public ActionResult SendLoginValidSMS(FormCollection form) { //step one :get customer cellphone from db string customerID = form["CustomerID"]; if (string.IsNullOrEmpty(customerID)) { return(Json("用户名未提供,发送验证码失败。", JsonRequestBehavior.AllowGet)); } string vendorUserCellphone = CommonService.GetVendorCellPhone(customerID); //step two :send sms if (string.IsNullOrEmpty(vendorUserCellphone)) { return(Json("账户未绑定手机或是未完成验证绑定,获取验证码失败。", JsonRequestBehavior.AllowGet)); } else { string code = ValidationCodeHelper.CreateValidateCode(5); Session["ValidateCode"] = code; CookieHelper.SaveCookie <string>("VerifyCode", code.Trim()); string SMSContent = string.Format(AppSettingManager.GetSetting("SMSTemplate", "CreateConfirmPhoneCode"), DateTime.Now.ToString("MM月dd日 HH:mm"), code); if (SMSService.SendSMS(vendorUserCellphone, SMSContent)) { return(Json("s", JsonRequestBehavior.AllowGet)); } } return(Json("服务器忙,稍后重试", JsonRequestBehavior.AllowGet)); }
private void simpleButton1_Click(object sender, EventArgs e) { SMSService sms = new SMSService(); bool result = sms.SendSMS("12674443111", "12674443111", "Third test from your number, with international code."); Mess.Info("Status: " + result); }
public objRegisterResponseModel RegisterUser(objRegisterRequestModel requestModel) { IAuthentication _repository = new DataAccess.Authentication.Authentication(); objRegisterResponseModel objResponse = new objRegisterResponseModel(); int Id = _repository.AddUser(requestModel.objUser); if (Id > 0) { UserModel user = new UserModel(); user.Id = Id; string OTP = GenerateNewOTP(); user.OTP = OTP; user.PhoneNo = requestModel.objUser.PhoneNo; user.FullName = requestModel.objUser.FullName; user.EmailId = requestModel.objUser.EmailId; objResponse.user = user; SMSService.SendSms(requestModel.objUser.PhoneNo, ("Login OTP " + user.OTP), user.OTP); AppResponseView response = new AppResponseView(); response.Message = "User Registered Successfully"; response.Status = 1; objResponse.Response = response; _repository.UpdateRegisterOTPCountForUser(requestModel.objUser.PhoneNo, true); } else { AppResponseView response = new AppResponseView(); response.Message = "User already Registered"; response.Status = 0; objResponse.Response = response; } return(objResponse); }
public LoginResponseModel ResendOTP(LoginRequestModel requestModel) { IAuthentication _repository = new DataAccess.Authentication.Authentication(); LoginResponseModel objResponse = new LoginResponseModel(); int Result = _repository.CheckPhoneNoExists(requestModel.UserName); if (Result > 0) { objResponse = _repository.GetRegisterOTPCountForUser(requestModel.UserName); DateTime Currentdate = DateTime.Now; DateTime OTPsentdate = Convert.ToDateTime(objResponse.RegisterOTPSentDate); int reslt = 0; if (objResponse.RegisterOTPSentDate == DateTime.MinValue) { string OTP = GenerateNewOTP(); objResponse.OTP = OTP; objResponse.Status = 1; objResponse.Message = "You have Another 2 chance to send OTP"; SMSService.SendSms(requestModel.UserName, (objResponse.OTP), objResponse.OTP); _repository.UpdateRegisterOTPCountForUser(requestModel.UserName, true); } else { reslt = DateTime.Compare(Currentdate.Date, OTPsentdate.Date); if (reslt != 0) { string OTP = GenerateNewOTP(); objResponse.OTP = OTP; objResponse.Status = 1; objResponse.RegisterOTPSentCount = 1; objResponse.Message = "You have Another 2 chance to send OTP"; SMSService.SendSms(requestModel.UserName, (objResponse.OTP), objResponse.OTP); _repository.UpdateRegisterOTPCountForUser(requestModel.UserName, true); } else if (reslt == 0 && objResponse.RegisterOTPSentCount < 3) { string OTP = GenerateNewOTP(); objResponse.OTP = OTP; objResponse.Status = 1; objResponse.RegisterOTPSentCount = objResponse.RegisterOTPSentCount + 1; int balance = 3 - Convert.ToInt32(objResponse.RegisterOTPSentCount); objResponse.Message = "You have another " + balance + " chance to send OTP"; SMSService.SendSms(requestModel.UserName, (objResponse.OTP), objResponse.OTP); _repository.UpdateRegisterOTPCountForUser(requestModel.UserName, false); } else if (reslt == 0 && objResponse.RegisterOTPSentCount >= 3) { objResponse.Status = 2; objResponse.RegisterOTPSentCount = 3; objResponse.Message = "You have Exceeded the limit of resending OTP"; } } } else { objResponse.Status = 0; } return(objResponse); }
public async Task <IActionResult> GetCheckListPointMarkDone(ApiRequest request) { try { FMSEmergencyCheck check = await dbContext.FMSEmergencyCheckList.Where(x => x.Id == request.FMSEmergencyCheckId).Select(x => x).SingleOrDefaultAsync(); Emergency emergency = await dbContext.Emergencies.Where(x => x.Id == check.FMSEmergencyId).SingleOrDefaultAsync(); check.MaintenanceStatus = CheckMaintenanceStatus.Done; emergency.LastUpdated = PakistanDateTime.Now; await dbContext.SaveChangesAsync(); string title = $"Accidental Job Vehicle Number {check.VehicleNumber}"; string notification = $"Check Point {check.Description} marked as done"; await hubContext.Clients.All.SendAsync("ReceiveMessageAllUsers", User.Identity.Name, title, notification); await SMSService.SendSMS(title + ": " + notification, "03035650720"); SMSService.SendMail(title, notification, "*****@*****.**"); return(Ok()); } catch (Exception ex) { return(BadRequest(ex.ToString())); } }
public MemberController(IHostingEnvironment env, ReservationDbContext dbcontext, NPOLJwtTokenService tokensrv, ServiceConfig serviceConfig, SMSService smsService) { db = dbcontext; tokenservice = tokensrv; this.serviceConfig = serviceConfig; this.smsService = smsService; membersPath = Path.Combine(env.WebRootPath, "images", "members"); }
public NegotiatedContentResult <string> TestEmailSend([FromBody] GetAgentAdminDetailsRequest request) { //EmailServices.SendMail("*****@*****.**", "Mail Title", "Mail Message Content"); //return Content(HttpStatusCode.OK, "Mail Sent"); SMSService.SendOTP("", ""); return(Content(HttpStatusCode.OK, "OTP Sent")); }
public async Task GetSmsList_ReturnsSomeRecords_Test() { var smsService = new SMSService(new FakeOdorikCredentials()); var result = await smsService.GetSentSMSsAsync(new SMSFilter { From = DateTime.Now.AddYears(-1), To = DateTime.Now }); Assert.IsTrue(result.Any()); }
public async Task GetAllowedSenders_ReturnCorrectSenders_Test() { var smsService = new SMSService(new FakeOdorikCredentials()); var result = await smsService.GetAllowedSendersAsync(); Assert.IsTrue(result.Any()); }
public async Task SendSms_SendSuccessfully_Test() { var smsService = new SMSService(new FakeOdorikCredentials()); var result = await smsService.SendSmsAsync("5517", "00420774123456", "Testing message from unit test."); Assert.IsTrue(result > 0); }
static void Main(string[] args) { DateTime checkDate = DateTime.Now.Date; string date = GetArg("CHECKDATE"); if (!string.IsNullOrWhiteSpace(date)) { checkDate = DateTime.ParseExact(date, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture); } using (var db = DB.GetContext()) { SMSService sms = new SMSService(); EmailService email = new EmailService(); var medicalNotifications = NotificationRepository.GetMedicalNotifications(db, checkDate); var licenseNotifications = NotificationRepository.GetLicenseNotifications(db, checkDate); //medicals foreach (var med in medicalNotifications) { if (!string.IsNullOrWhiteSpace(med.CellPhone)) SendSMS(db, sms, med); if (!string.IsNullOrWhiteSpace(med.Email)) SendEmail(db, email, med); } //licenses foreach (var lic in licenseNotifications) { if (!string.IsNullOrWhiteSpace(lic.CellPhone)) SendSMS(db, sms, lic); if (!string.IsNullOrWhiteSpace(lic.Email)) SendEmail(db, email, lic); } } }
protected void updateUserProfile(object sender, EventArgs e) { SqlConnection dbConnection = new SqlConnection("Data Source=itksqlexp8;Integrated Security=true"); try { dbConnection.Open(); dbConnection.ChangeDatabase("nasa_SilentAuction_v1"); string name = Session["user_id"] as string; str = "Update users set firstName='" + fname.Text + "', lastName='" + lname.Text + "', addressLine1='" + addressLine1.Text + "', addressLine2='" + addressLine2.Text + "', city='" + city.Text + "', stateName='" + state.Text + "', phoneHome='" + phoneNumber.Text + "', phncarrier='" + networkProvider.SelectedValue + "', email='" + email.Text + "', password='******' WHERE userID='" + userid1.Text + "'"; SqlCommand sqlCommand = new SqlCommand(str, dbConnection); var x = sqlCommand.ExecuteNonQuery(); string message = "Bingo! your profile has been Updated. For confirmation we have sent you an email, Happy Bidding :)" ; textMessage = new SMSService(networkProvider.Text, phoneNumber.Text, message); textMessage.SendTextMessage(textMessage); UpdateReply.Text = "Data Updated Successfully, Please check your inbox :)"; } catch (SqlException exception) { Response.Write("<p>Error code " + exception.Number + ": " + exception.Message + "</p>"); } }