protected void Page_Load(object sender, EventArgs e) { if (Session["UserId"] == null) { Response.Redirect("../Login.aspx"); } if (!IsPostBack) { BusinessLayer.SMS.SMSTrigger objTrigger = new BusinessLayer.SMS.SMSTrigger(); Hidden1.Value = (objTrigger.IsMessageSentToday() == true) ? "1" : "0"; if (Hidden1.Value == "1") { btnSend.Style.Add("display", "none"); } else { btnSend.Style.Add("display", "block"); } ddlDays.SelectedValue = DateTime.Now.Day.ToString(); ddlMonth.SelectedValue = DateTime.Now.Month.ToString(); ddlYear.SelectedValue = DateTime.Now.Year.ToString(); BStrMssg(); } }
protected void LoadSMSMemberSubscriptionList() { BusinessLayer.SMS.SMSTrigger objSMSTrigger = new BusinessLayer.SMS.SMSTrigger(); DataTable dt = objSMSTrigger.MemberSetails_GetAll(SMSMemberId); if (dt != null) { dgvMemberMaster.DataSource = dt; dgvMemberMaster.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["UserId"] == null) { Response.Redirect("../Login.aspx"); } if (!IsPostBack) { BusinessLayer.SMS.SMSTrigger objTrigger = new BusinessLayer.SMS.SMSTrigger(); btnUnlock.Enabled = (objTrigger.IsMessageSentToday() == true) ? true : false; } }
protected void btnSend_Click(object sender, EventArgs e) { BusinessLayer.SMS.ApiConfiguration ObjApi = new BusinessLayer.SMS.ApiConfiguration(); DataTable dt = ObjApi.GetAll(); DataView DV = new DataView(dt); DV.RowFilter = "IsActive = 1"; string mobiles = ""; string message = FitMessage(txtMssg.Text.Trim()); int smsPerTrans = 20; int memberType = 1; //1=All, 2=Only Paid,3=Only UnPaid BusinessLayer.SMS.SMSTrigger objTrigger = new BusinessLayer.SMS.SMSTrigger(); //string ROUTE_1 = System.Configuration.ConfigurationSettings.AppSettings["ROUTE_1"]; //string ROUTE_2 = System.Configuration.ConfigurationSettings.AppSettings["ROUTE_2"]; //API_INDEX = ROUTE_1; string API = string.Empty; API_INDEX = Convert.ToString(DV[0]["SMSAPIId"]); string strUrl; string dataString; int MobNoCount = 0; try { if (txtMobiles.Text.Trim().Length > 0) { string[] Arrmob = txtMobiles.Text.Trim().Split(','); for (int i = 0; i < Arrmob.Length; i++) { if (Arrmob[i].Length == 10) { if (API_INDEX == "1") { mobiles += "91" + Arrmob[i].Trim() + ","; } else if (API_INDEX == "2" || API_INDEX == "3" || API_INDEX == "4") { mobiles += Arrmob[i].Trim() + ","; } else if (API_INDEX == "5") { mobiles += "91" + Arrmob[i].Trim() + ";"; } } else if (Arrmob[i].Length == 12) { if (API_INDEX == "1") { mobiles += Arrmob[i].Trim() + ","; } else if (API_INDEX == "2" || API_INDEX == "3" || API_INDEX == "4") { mobiles += Arrmob[i].Trim().Substring(2) + ","; } else if (API_INDEX == "5") { mobiles += Arrmob[i].Trim() + ";"; } } } if (mobiles.Trim().Length > 0) { mobiles = mobiles.Trim().Substring(0, mobiles.Length - 1).Trim(); strUrl = GetHTTPAPI(mobiles, message); WebRequest request1 = HttpWebRequest.Create(strUrl); HttpWebResponse response1 = (HttpWebResponse)request1.GetResponse(); Stream s1 = (Stream)response1.GetResponseStream(); StreamReader readStream1 = new StreamReader(s1); dataString = readStream1.ReadToEnd(); response1.Close(); s1.Close(); readStream1.Close(); } } else { DataSet Ds = new DataSet(); DataTable DTMobNos = getMobileNumbers(memberType);//Fetch mobile numbers from Member tables based on MemberType(pritam) DataView Dv; Dv = new DataView(DTMobNos); Dv.RowFilter = "Priority = 0"; //Route 1 Ds.Tables.Add(Dv.ToTable("TBL_PRIORITY_0")); Dv = new DataView(DTMobNos); Dv.RowFilter = "Priority = 1"; //Route 2 Ds.Tables.Add(Dv.ToTable("TBL_PRIORITY_1")); foreach (DataTable DT in Ds.Tables) { if (DT.Rows.Count > 0) { //if (DT.Rows[0]["Priority"].ToString().Equals("0")) // API_INDEX = ROUTE_1; //else if (DT.Rows[0]["Priority"].ToString().Equals("1")) //API_INDEX = ROUTE_2; int counter = 0; mobiles = ""; foreach (DataRow DR in DT.Rows) { if (API_INDEX == "1") { mobiles += "91" + DR["MobileNo"].ToString() + ","; } else if (API_INDEX == "2" || API_INDEX == "3" || API_INDEX == "4") { mobiles += DR["MobileNo"].ToString() + ","; } else if (API_INDEX == "5") { mobiles += "91" + DR["MobileNo"].ToString() + ";"; } MobNoCount++; counter++; if (counter == smsPerTrans) { mobiles = mobiles.Trim().Substring(0, mobiles.Length - 1).Trim(); strUrl = GetHTTPAPI(mobiles, message); WebRequest request = HttpWebRequest.Create(strUrl); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream s = (Stream)response.GetResponseStream(); StreamReader readStream = new StreamReader(s); dataString = readStream.ReadToEnd(); response.Close(); s.Close(); readStream.Close(); counter = 0; mobiles = ""; } } if (mobiles.Trim().Length > 0) { mobiles = mobiles.Trim().Substring(0, mobiles.Length - 1).Trim(); strUrl = GetHTTPAPI(mobiles, message); WebRequest request1 = HttpWebRequest.Create(strUrl); HttpWebResponse response1 = (HttpWebResponse)request1.GetResponse(); Stream s1 = (Stream)response1.GetResponseStream(); StreamReader readStream1 = new StreamReader(s1); dataString = readStream1.ReadToEnd(); response1.Close(); s1.Close(); readStream1.Close(); } } } } ShowMsg("Message Send Successfully"); } catch (Exception ex) { ShowMsg(ex.Message); } finally { if (txtMobiles.Text.Trim().Length == 0) { if (MobNoCount > 0) { objTrigger.Save(MobNoCount); Hidden1.Value = "1"; btnSend.Style.Add("display", "none"); } } } }
protected void btnUnlock_Click(object sender, EventArgs e) { BusinessLayer.SMS.SMSTrigger objTrigger = new BusinessLayer.SMS.SMSTrigger(); objTrigger.Unlock(); btnUnlock.Enabled = false; }