PageRenderTime 45ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/receivesms.aspx.cs

https://bitbucket.org/xpertech/paycell
C# | 63 lines | 55 code | 1 blank | 7 comment | 11 complexity | 5a25bd77b60cf83f1e6774bef45bf350 MD5 | raw file
  1. using System;
  2. using System.Collections;
  3. using System.Configuration;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Web;
  7. using System.Web.Security;
  8. using System.Web.UI;
  9. using System.Web.UI.HtmlControls;
  10. using System.Web.UI.WebControls;
  11. using System.Web.UI.WebControls.WebParts;
  12. using System.Xml.Linq;
  13. public partial class receivesms : System.Web.UI.Page
  14. {
  15. const int MobileNoLength = 10;
  16. protected void Page_Load(object sender, EventArgs e)
  17. {
  18. try
  19. {
  20. Logs.Write("OK1");
  21. //string smsmsg = Request.Params["message"].ToString();
  22. //string to = Request.Params["to"].ToString();
  23. //string from = Request.Params["from"].ToString();
  24. string smsmsg = Request.QueryString["message"];
  25. string to = Request.QueryString["to_number"];
  26. string from = Request.QueryString["from_number"];
  27. Logs.Write(DateTime.Now.ToString());
  28. Logs.Write(from);
  29. Logs.Write(to);
  30. Logs.Write(smsmsg);
  31. if (from != null && from.Trim().Length > 0 && smsmsg != null && smsmsg.Trim().Length > 0)
  32. {
  33. if (from.Contains('+'))
  34. {
  35. from = from.Remove(from.IndexOf('+'), 1);
  36. }
  37. if (from.Length > MobileNoLength)
  38. {
  39. from = from.Substring(from.Length - MobileNoLength, MobileNoLength);
  40. }
  41. else if (from.Length < MobileNoLength)
  42. {
  43. Response.Write("Invalid mobile number.");
  44. return;
  45. }
  46. if (to.Length > MobileNoLength)
  47. {
  48. to = to.Substring(to.Length - MobileNoLength, MobileNoLength);
  49. }
  50. SqlHelper.ExecuteNonQuery(GlobalVariable.con, CommandType.Text, "insert into tbl_inbox (MsgTo,MsgFrom,MsgText,MsgDate) values('" + to + "','" + from + "','" + smsmsg + "','" + DateTime.Now + "')");
  51. //if (smsmsg == "STOP")
  52. //{
  53. // //SqlHelper.ExecuteNonQuery(GlobalVariable.con, CommandType.Text, "delete from tbl_groupcontacts where MobileNumber='" + from + "'");
  54. //}
  55. }
  56. }
  57. catch (Exception exp)
  58. {
  59. Response.Write(exp.ToString());
  60. }
  61. }
  62. }