public static object GetAllStudents() { try { using (var context = new SMSModel()) { var a_student = (from each_student in context.student join each_user in context.user on each_student.s_id equals each_user.Id join each_dep in context.department on each_user.dep_id equals each_dep.dep_id select new { s_id = each_student.s_id, s_name = each_user.name, dep_id = each_dep.dep_id, dep_name = each_dep.dep_name, grade = each_student.grade, email = each_user.email, tel = each_user.tel, password = each_user.password }); var stuArray = a_student.ToList(); Console.WriteLine(stuArray); return(Helper.JsonConverter.BuildResult(stuArray)); } } catch (Exception e) { Console.Write(e); return(Helper.JsonConverter.Error(410, "数据库中可能存在不一致现象,请检查")); } }
public int Add(SMSModel model) { //string sql = "insert into [SMS] ([Content],[CreateTime],[SendUser],[SendUserName], [SendTime],[SendTo]) " + // "values(@Content,GETDATE(),@SendUser,@SendUserName,@SendTime,@SendTo)"; string sql = "insert into [SMS] ([Content],[CreateTime],[SendUser],[SendUserName],[SendTo],[IsSended]) " + "values(@Content,GETDATE(),@SendUser,@SendUserName,@SendTo,1)"; SqlParameter[] para = new SqlParameter[] { new SqlParameter("@Content", SqlDbType.NVarChar) { Value = model.Content }, new SqlParameter("@SendUser", SqlDbType.UniqueIdentifier) { Value = model.SendUser }, new SqlParameter("@SendUserName", SqlDbType.NChar, 50) { Value = model.SendUserName }, //new SqlParameter("@SendTime", SqlDbType.DateTime) {Value = model.SendTime}, new SqlParameter("@SendTo", SqlDbType.VarChar) { Value = model.SendTo } }; return(dbHelper.Execute(sql, para)); }
public static object GetAllTeachers() { try { using (var context = new SMSModel()) { var a_teacher = (from each_teacher in context.teacher join each_user in context.user on each_teacher.t_id equals each_user.Id join each_dep in context.department on each_user.dep_id equals each_dep.dep_id select new { t_id = each_teacher.t_id, t_name = each_user.name, dep_id = each_dep.dep_id, dep_name = each_dep.dep_name, job_title = each_teacher.job_title, email = each_user.email, tel = each_user.tel, password = each_user.password }); var teaArray = a_teacher.ToList(); Console.WriteLine(teaArray); return(Helper.JsonConverter.BuildResult(teaArray)); } } catch (Exception e) { Console.Write(e); return(Helper.JsonConverter.Error(410, "数据库中可能存在不一致现象,请检查")); } }
private void btnSubmit_Click(object sender, RoutedEventArgs e) { Info info = new Info(); string header = txtHeader.Text; string smsSender = txtSender.Text.Replace(" ", String.Empty); string message = txtMessage.Text; bool headerOk = Message.HeaderOk(header); Regex checkPhone = new Regex("\\+(9[976]\\d|8[987530]\\d|6[987]\\d|5[90]\\d|42\\d|3[875]\\d|2[98654321]\\d|9[8543210]|8[6421]|6[6543210]|5[87654321]|4[987654310]|3[9643210]|2[70]|7|1)\\d{1,14}$"); Match phoneMatch = checkPhone.Match(smsSender); bool pm = phoneMatch.Success; if (!headerOk || !header.ToUpper().StartsWith("S")) { info.DisplayMessage("Incorrect Header", "SMS Header must begin with 'S', followed by 9 numbers"); } else if (!phoneMatch.Success) { info.DisplayMessage("Sender Incorrect", "Please enter a phone number, including the area code in the sender box."); } else if (message == "") { info.DisplayMessage("No Message", "Please enter a message"); } else { txtMessage.Text = string.Join(" ", TSA.ReplaceWords(txtMessage.Text.Split(' '))); SMSModel sms = new SMSModel(header, txtMessage.Text, smsSender); sms.OutputJson(); info.DisplayMessage("Success", "SMS submitted successfuly"); } }
private static List <SMSModel> GetSMS(string selection, string[] selectionArgs) { var listOfSMS = new List <SMSModel>(); try { var context = Application.Context.ApplicationContext; var projection = new string[] { "_id", "address", "body", "date" }; var sortOrder = "_id ASC"; var cursor = context.ContentResolver.Query(Telephony.Sms.Inbox.ContentUri, projection, selection, selectionArgs, sortOrder); if (cursor.MoveToFirst()) { do { var sms = new SMSModel(); sms.SMSId = cursor.GetInt(cursor.GetColumnIndex("_id")); sms.Address = cursor.GetString(cursor.GetColumnIndex("address")); sms.Body = cursor.GetString(cursor.GetColumnIndex("body")); sms.UnixDate = cursor.GetString(cursor.GetColumnIndex("date")); listOfSMS.Add(sms); } while (cursor.MoveToNext()); } } catch (Exception ex) { } return(listOfSMS); }
/// <summary> /// Create Jobseeker SMS /// </summary> /// <param name="model"></param> /// <returns>The SMS message ID.</returns> public long CreateSMS(SMSModel model) { var request = model.ToSMSJNMMessageRequest(); ValidateRequest(request); try { var service = Client.Create <IDiaryNotification>("DiaryNotification.svc"); var response = service.CreateSMSMessage(request); ValidateResponse(response); return(response.MessageId); } catch (FaultException <ValidationFault> vf) { throw vf.ToServiceValidationException(); } catch (FaultException fe) { throw fe.ToServiceValidationException(); } }
public static void SendSMS(SMSModel SMS) { try { if (SMS != null) { Console.WriteLine("Sending sms to phone number: " + SMS.PhoneNumber); _smsManager = SmsManager.Default; string SmsId = SMS.Id.ToString(); if (SentIntent.Extras != null) { SentIntent.Extras.Clear(); } SentIntent.PutExtra("SMSGatewayId", SmsId); SentIntent.PutExtra("Message", SMS.Message); SentIntent.PutExtra("PhoneNumber", SMS.PhoneNumber); var piSent = PendingIntent.GetBroadcast(Application.Context, SMS.Id, SentIntent, 0); var piDelivered = PendingIntent.GetBroadcast(Application.Context, 0, new Intent("SMS_DELIVERED"), 0); SMS.Status = "Mengirim"; UpdateSMS(SMS); _smsManager.SendTextMessage(SMS.PhoneNumber, null, SMS.Message, piSent, piDelivered); } } catch (Exception Ex) { Console.WriteLine(Ex.Message + Ex.StackTrace); } }
public static object ChangePassword(object json) { try { Dictionary <string, string> body = JsonConverter.Decode(json); var Id = int.Parse(body["Id"]); var oldPassword = body["oldPassword"]; var newPassword = body["newPassword"]; using (var context = new SMSModel()) { var a_user = context.user.Find(Id); if (a_user.password == oldPassword) { a_user.password = newPassword; context.SaveChangesAsync(); return(Helper.JsonConverter.BuildResult("成功")); } else { return(Helper.JsonConverter.Error(410, "密码不正确")); } } } catch (Exception e) { Console.Write(e); return(Helper.JsonConverter.Error(410, "数据库中可能存在不一致现象,请检查")); } }
/// <summary>Update /// </summary> /// <param name="device"></param> /// <returns></returns> public int Update(SMSModel model) { string sql = string.Format(@" update SMS set SMSId = @SMSId , [Type] = @Type , ValidTime = @ValidTime, BeginTime = @BeginTime, UserID = @UserID, Content = @Content where ID=@ID "); SQLiteParameter[] parameters = { new SQLiteParameter("@SMSId", model.SMSId), new SQLiteParameter("@Type", model.Type), new SQLiteParameter("@ValidTime", model.ValidTime), new SQLiteParameter("@BeginTime", model.BeginTime), new SQLiteParameter("@UserID", model.UserID), new SQLiteParameter("@Content", model.Content), new SQLiteParameter("@ID", model.ID) }; return(SqliteHelper.ExecuteNonQuery(sql, parameters)); }
public static object PostClass(object json) { Dictionary <string, string> body = JsonConverter.Decode(json); var course_name = body["course_name"]; var dep_id = int.Parse(body["dep_id"]); var t_id = int.Parse(body["t_id"]); var credits = int.Parse(body["credits"]); try { using (var context = new SMSModel()) { course course = new course(); course.course_name = course_name; course.dep_id = dep_id; course.t_id = t_id; course.credits = credits; course.broadCast = ""; context.course.Add(course); context.SaveChangesAsync(); return(Helper.JsonConverter.BuildResult("成功")); } } catch (Exception e) { Console.Write(e); return(Helper.JsonConverter.Error(410, "数据库中可能存在不一致现象,请检查")); } }
public string GetSMSCode(string phone) { object obj = new { timestamp = (DateTime.Now - DateTime.Parse("1970-01-01 00:00:00")).TotalMilliseconds, mobile = phone }; requestModel req = new requestModel() { pId = System.Configuration.ConfigurationManager.ConnectionStrings["pid"].ConnectionString, encryptContent = AESHelper.AESEncrypt(JsonConvert.SerializeObject(obj)) }; try { string res = HttpWebResponseUtility.CreatePostDataResponse(System.Configuration.ConfigurationManager.ConnectionStrings["url"].ConnectionString + System.Configuration.ConfigurationManager.ConnectionStrings["getsmscode"].ConnectionString, JsonConvert.SerializeObject(req)); responseModel response = JsonConvert.DeserializeObject <responseModel>(res); if (response.status.Equals("success")) { AESHelper.AESDecrypt(response.encryptionBody); SMSModel smsmodel = JsonConvert.DeserializeObject <SMSModel>(AESHelper.AESDecrypt(response.encryptionBody)); return(smsmodel.sms_code); } else { throw new Exception(response.message); } } catch (Exception ex) { throw ex; } }
public static object ChangeBroadCast(object json) { try { Dictionary <string, string> body = JsonConverter.Decode(json); var course_id = int.Parse(body["course_id"]); var broadCast = body["broadCast"]; using (var context = new SMSModel()) { var a_course = context.course.Find(course_id); if (a_course == null) { return(Helper.JsonConverter.Error(410, "查无此班级")); } else { a_course.broadCast = broadCast; context.SaveChangesAsync(); return(Helper.JsonConverter.BuildResult("成功")); } } } catch (Exception e) { Console.Write(e); return(Helper.JsonConverter.Error(410, "数据库中可能存在不一致现象,请检查")); } }
public static object GiveScore(object json) { try { Dictionary <string, string> body = JsonConverter.Decode(json); var s_id = int.Parse(body["s_id"]); var course_id = int.Parse(body["course_id"]); var grade = int.Parse(body["grade"]); using (var context = new SMSModel()) { var a_user = context.student_class.Find(course_id, s_id); a_user.grade = grade; context.SaveChangesAsync(); return(Helper.JsonConverter.BuildResult("成功")); } } catch (Exception e) { Console.Write(e); return(Helper.JsonConverter.Error(410, "数据库中可能存在不一致现象,请检查")); } }
public JsonResult SendSMS(SMSModel smsModel) { var results = new List <MessageResult>(); var client = ClientService.GetClientById(smsModel.Client.Id); var messageText = MessageService.PopulatePlaceHoldersSms(client); var downloadMessageText = MessageService.GenerateDownLinksSMSText(); LogProgress($"Sending SMS :: {messageText}"); // Get user mobile numbers and loop through each one to send SMS foreach (var user in smsModel.Users) { try { var result = MessageService.SendSms(user.PhoneNumber, messageText); LogProgress($"{(result.IsOk ? "SUCCESS" : "FAILED")} :: SMS to {user.PhoneNumber}. " + $"{(result.Exception == null ? string.Empty : result.Exception.Message)}"); if (result.IsOk) { UserService.MarkSmsSent(user.Id); } result = MessageService.SendSms(user.PhoneNumber, downloadMessageText); LogProgress($"{(result.IsOk ? "SUCCESS" : "FAILED")} :: Download SMS to {user.PhoneNumber}. " + $"{(result.Exception == null ? string.Empty : result.Exception.Message)}"); } catch (Exception ex) { LogProgress($"Failed to send SMS to {user.PhoneNumber} : {ex.Message}"); } } LogProgress($"Sending SMS complete!"); return(CreateJsonResult("Sending SMS complete!")); }
/// <summary>删除短消息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDelete_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtSmsID.Text)) { this.lblMsg.Visible = true; this.lblMsg.Text = "Please input SmdID."; return; } lblMsg.Visible = false; SMSModel model = _bll.Get(txtSmsID.Text); if (null == model) { this.lblMsg.Visible = true; this.lblMsg.Text = "The SMS is not exist."; return; } lblMsg.Visible = false; if (_bll.Delete(txtSmsID.Text) > 0) { LoadAllSMS(); // this.lblMsg.Visible = true; this.lblMsg.Text = "Operate successful."; } else { this.lblMsg.Visible = true; this.lblMsg.Text = "Operate fail."; } }
/// <summary> /// 发送短信同步 /// </summary> /// <param name="mobile"></param> /// <param name="content"></param> /// <returns></returns> public static string SendSMS(List <string> mobile, string content) { SMSModel m = new SMSModel { mobile = mobile.ListToString(), sendContents = content }; return(SendInfo_t(m)); }
/// <summary> /// Convert to the SMSJNM message request. /// </summary> /// <param name="src">The source.</param> /// <returns></returns> public static SMSJNMMessageRequest ToSMSJNMMessageRequest(this SMSModel src) { var dest = new SMSJNMMessageRequest(); dest.jobseekerId = src.JobseekerID; dest.subjectArea = src.ContractType; dest.smsPhone = src.Phone; dest.smsMessage = src.Message; return(dest); }
public IActionResult SendSMS(SMSPublicModel model) { model.FormBehavior = new FormBehavior(); CaptchaResponse response = ValidateCaptcha(HttpContext.Request.Form["g-recaptcha-response"]); if (!response.Success) { ModelState.AddModelError(string.Empty, "Please click captcha for security purposes."); } else if (ModelState.IsValid) { try { var sms = new SMSModel { MobileNumber = model.MobileNumber, MessageBody = $"From: {model.SenderName}\n{model.MessageBody}\n\nDon't reply to this number." }; var record = _mapper.Map <SMSModel, ShortMessageService>(sms); record.SMSStatus = Enums.SMSStatus.Queue; _smsService.NewSMS(record, true); model.FormBehavior.Notification = new Notification { IsError = false, Message = "Message successfully queued.", Title = "SMS" }; model.MobileNumber = string.Empty; model.MessageBody = string.Empty; model.SenderName = string.Empty; ModelState.Clear(); } catch (Exception ex) { if (ex.Message.Contains("mobile number")) { ModelState.AddModelError(string.Empty, "Invalid format of mobile number."); } else if (ex.Message.Contains("unicode")) { ModelState.AddModelError(string.Empty, "Message body should not contain unicode characters (ex. emojis)"); } else { model.FormBehavior.Notification = new Notification { IsError = true, Message = ex.Message, Title = "SMS" }; } } } return(PartialView("_SendSMS", model)); }
public static SMSDto ToDto(this SMSModel sms) { return(new SMSDto() { DestinationNumber = sms.DestinationNumber, ExternalPrice = sms.ExternalPrice, LineId = sms.LineId, SMSId = sms.SMSId, Line = sms.Line.ToDto() }); }
public async Task SendSMS([FromBody] SMSModel model) { await smsService.SendAsync(new SendSMSOptions() { Destinations = new List <string>() { model.Phone, }, Message = model.Content }); }
/// <summary> /// 发送短信异步 群发 /// </summary> /// <param name="mobile"></param> /// <param name="content"></param> /// <returns></returns> public static string SendSMS_ASYN(List <string> mobile, string content) { SMSModel m = new SMSModel { mobile = mobile.ListToString(), sendContents = content }; ThreadPool.QueueUserWorkItem(new WaitCallback(SendInfo), m); return("ok"); }
/// <summary> /// 发送短信异步 群发 /// </summary> /// <param name="mobile"></param> /// <param name="content"></param> /// <returns></returns> public static string SendSMS_ASYN(List<string> mobile, string content) { SMSModel m = new SMSModel { mobile = mobile.ListToString(), sendContents = content }; ThreadPool.QueueUserWorkItem(new WaitCallback(SendInfo), m); return "ok"; }
public IActionResult New() { SMSModel model = new SMSModel { FormType = Global.FormType.Create, UserHandler = _userHandler, IsRecordOwner = true }; return(View("Form", model)); }
public ActionResult Index(SMSModel m) { if (m == null) { m = new SMSModel(); } else { UpdateModel(m.Pager); } return(View(m)); }
public SMSEntity ConvertSMS(SMSModel originalSMS) { SMSEntity convertedSMS = new SMSEntity { SMSId = originalSMS.Id, LineId = originalSMS.LineId, DateCreated = originalSMS.DateActivityMade, DestinationNumber = originalSMS.DestinationNumber }; return(convertedSMS); }
private SMSModel GenerateSMS(LineModel line) { Thread.Sleep(5); SMSModel newSMS = new SMSModel(); var gen = new Generator(); newSMS.LineId = line.LineId; newSMS.DestinationNumber = gen.GeneratePhoneNumber(); // gets string that starts with "05" + 8 random numbers newSMS.DateActivityMade = gen.GenerateDate(); return(newSMS); }
// Device = "http://api.silverstreet.com/send.php"; public static string SendSMS(SMSModel smsmodel, string CountryFormat) { if (smsmodel.RecipientNumber == null) { return(null); } sender = smsmodel.Sender.Replace(" ", string.Empty); smsmodel.Message = smsmodel.Message.Replace("(%FIRSTNAME%)", smsmodel.FirstName); smsmodel.Message = smsmodel.Message.Replace("(%LASTNAME%)", smsmodel.LastName); smsmodel.Message = smsmodel.Message.Replace("((%PREFERREDNAME%))", smsmodel.PreferredName); if (smsmodel.isShortCode) { sendMessage = Uri.EscapeUriString(smsmodel.Message); } else { sendMessage = Uri.EscapeUriString(smsmodel.Message); } mbnumber = smsmodel.RecipientNumber; //replace + sign in number mbnumber = mbnumber.Replace("+", string.Empty); //replace - sign in number mbnumber = mbnumber.Replace("-", string.Empty); //replace ( sign in number mbnumber = mbnumber.Replace("(", string.Empty); //replace ) sign in number mbnumber = mbnumber.Replace(")", string.Empty); //replace " " sign in number mbnumber = mbnumber.Replace(" ", string.Empty); //remove white space charcters mbnumber = mbnumber.Trim(); if (CountryFormat == "MY") { return(SMSSenderMY(mbnumber, sender, sendMessage, smsmodel.Device, smsmodel.isShortCode)); } else if (CountryFormat == "US") { return(SMSSenderUS(mbnumber, sender, sendMessage, smsmodel.Device, smsmodel.isShortCode)); } else if (CountryFormat == "SG") { return(SMSSenderSG(mbnumber, sender, sendMessage, smsmodel.Device, smsmodel.isShortCode)); } else { return(SMSSender(mbnumber, sendMessage, smsmodel.Device)); } }
public void CreateSms(SMSModel sms) { db.Sms.Add(new Sms() { textSms = sms.textSms, recipientSms = sms.recipientSms, dateSms = sms.dateSms, costSMS = sms.costSMS, idClient = sms.idClient, incomingSms = sms.incomingSms }); Save(); }
/// <summary> /// InsertSms /// </summary> public bool InsertSms(SMSModel obj) { Helpers.Connection.sConnectionStringDatabase = ConfigurationManager.ConnectionStrings["sConnectionString_Crm"].ConnectionString; SMSLibrary.SMSLibrary objSMS = new SMSLibrary.SMSLibrary(); if (objSMS.InsertSms(obj.MappingToSMS())) { return(true); } else { return(false); } }
public async Task <IServiceResult> SendAsync(SMSModel sms) { Log.Debug($"ParsGreenSMSService.SendAsync.Begin => {sms}"); try { //var response = await new SendSMSSoapClient(new SendSMSSoapClient.EndpointConfiguration() { }) // .SendAsync(_appSetting.SMSConfig.Signature, sms.PhoneNo, sms.TextBody, string.Empty); #region get var client = new RestClient("http://login.parsgreen.com/"); var request = new RestRequest("UrlService/sendSMS.ashx", Method.GET); request.AddParameter("from", _appSetting.SMSConfig.Number); request.AddParameter("to", sms.PhoneNo); request.AddParameter("text", sms.TextBody); request.AddParameter("signature", ""); var response = await client.ExecuteAsync <string>(request); Log.Debug($"ParsGreenSMSService.SendAsync.End => {response}"); if (response.StatusCode == HttpStatusCode.OK) { if (response.Data == string.Empty) { return(DataTransferer.Ok()); } } #endregion #region post //var client = new RestClient("http://login.parsgreen.com/"); //var request = new RestRequest("UrlService/sendSMS.ashx", Method.POST); //var bodyparams = new Dictionary<string, string> { // ["from"] = "", // ["to"] = sms.PhoneNo, // ["text"] = sms.TextBody, // ["signature"] = "", //}; //request.AddBody(bodyparams); //var response = client.Execute<string>(request); #endregion } catch (Exception ex) { Log.Error(ex, ex.Source); } return(DataTransferer.InternalServerError()); }
/// <summary> /// 发送短信同步 /// </summary> /// <param name="mobile"></param> /// <param name="content"></param> /// <returns></returns> public static string SendSMS(string mobile, string content) { if (!mobile.MobileVerify() || content.Length <= 0) { return("fail"); } SMSModel m = new SMSModel { mobile = mobile, sendContents = content }; return(SendInfo_t(m)); }
/// <summary> /// 发送短信同步 /// </summary> /// <param name="mobile"></param> /// <param name="content"></param> /// <returns></returns> public static string SendSMS(string mobile, string content) { if (!mobile.MobileVerify() || content.Length <= 0) { return "fail"; } SMSModel m = new SMSModel { mobile = mobile, sendContents = content }; return SendInfo_t(m); }
/// <summary> /// 发送短信异步 单发 /// </summary> /// <param name="mobile"></param> /// <param name="content"></param> /// <returns></returns> public static string SendSMS_ASYN(string mobile, string content) { if (!mobile.MobileVerify() || content.Length <= 0) { return "fail"; } SMSModel m = new SMSModel { mobile = mobile, sendContents = content }; ThreadPool.QueueUserWorkItem(new WaitCallback(SendInfo), m); return "ok"; }
public ActionResult SMS() { SMSConfigInfo smsConfigInfo = BSPConfig.SMSConfig; SMSModel model = new SMSModel(); model.Url = smsConfigInfo.Url; model.UserName = smsConfigInfo.UserName; model.Password = smsConfigInfo.Password; model.FindPwdBody = smsConfigInfo.FindPwdBody; model.SCVerifyBody = smsConfigInfo.SCVerifyBody; model.SCUpdateBody = smsConfigInfo.SCUpdateBody; model.WebcomeBody = smsConfigInfo.WebcomeBody; return View(model); }
/// <summary> /// 发送短信同步 /// </summary> /// <param name="mobile"></param> /// <param name="content"></param> /// <returns></returns> public static string SendSMS(List<string> mobile, string content) { SMSModel m = new SMSModel { mobile = mobile.ListToString(), sendContents = content }; return SendInfo_t(m); }
public ActionResult SMS(SMSModel model) { if (ModelState.IsValid) { SMSConfigInfo smsConfigInfo = BSPConfig.SMSConfig; smsConfigInfo.Url = model.Url; smsConfigInfo.UserName = model.UserName; smsConfigInfo.Password = model.Password; smsConfigInfo.FindPwdBody = model.FindPwdBody; smsConfigInfo.SCVerifyBody = model.SCVerifyBody; smsConfigInfo.SCUpdateBody = model.SCUpdateBody; smsConfigInfo.WebcomeBody = model.WebcomeBody; BSPConfig.SaveSMSConfig(smsConfigInfo); SMSes.ResetSMS(); AddAdminOperateLog("修改短信设置"); return PromptView(Url.Action("sms"), "修改短信设置成功"); } return View(model); }
private static string SendInfo_t(SMSModel m) { string param = "?"; param += "CorpID=" + SMSKey; param += "&Pwd=" + SMSPwd; param += "&Mobile=" + m.mobile; param += "&Content=" + HttpUtility.UrlEncode(m.sendContents, myEncoding); param += "&Cell="; param += "&SendTime="; string ct = RequestUrl(URL_SEND_SMS, param); if (ct.Trim() == "1") { return "ok"; } else { return "fail"; } }