protected void Retrimitere(object sender, EventArgs e) { var grdrow = (GridViewRow)((LinkButton)sender).NamingContainer; string id = grdrow.Cells[0].Text; var smsArchiveManager = new SmsArchiveManager(ConfigurationManager.ConnectionStrings["fccl_v2"].ConnectionString); var sms = smsArchiveManager.GetSmsById(id); SmsHelper.SendSms(sms); BindData(); }
public void BindData() { var smsArchiveManager = new SmsArchiveManager(ConfigurationManager.ConnectionStrings["fccl_v2"].ConnectionString); var values = smsArchiveManager.GetAllUnsendSms(); GridView1.Columns[0].Visible = true; GridView1.DataSource = values; GridView1.DataBind(); GridView1.Columns[0].Visible = false; }
public void RunProcess(string[] args) { Logger.Info("SendSmsWorker | Sms Worker started"); var smsArchiveManager = new SmsArchiveManager(ConfigurationManager.ConnectionStrings["fccl_v2"].ConnectionString); Sms sms = null; while ((sms = smsArchiveManager.Dequeue()) != null) { Logger.Info(string.Format("SendSmsWorker | Sending sms with Id: {0}", sms.Id)); SmsHelper.SendSms(sms); } }
public static void SendSms(Sms sms) { var smsArchiveManager = new SmsArchiveManager(ConfigurationManager.ConnectionStrings["fccl_v2"].ConnectionString); SerialPort port = new SerialPort(); clsSMS objclsSMS = new clsSMS(); string portname = ConfigurationManager.AppSettings["ComPort"].ToString(); string baudrate = "57600"; port = objclsSMS.OpenPort(portname, baudrate); try { if (objclsSMS.sendMsg(port, portname, "57600", sms.CellNr, sms.Message)) { Logger.Info(string.Format("SendSmsWorker | Sms-ul cu id-ul: {0} a fost trimis", sms.Id)); sms.DateSend = DateTime.Now; smsArchiveManager.UpdateSms(sms); } else { sms.TryNr++; smsArchiveManager.UpdateSms(sms); Logger.Error(string.Format("SendSmsWorker | Trimitere esuata a sms-ului cu id-ul: {0}", sms.Id)); } objclsSMS.ClosePort(port); } catch (Exception ex) { sms.TryNr++; smsArchiveManager.UpdateSms(sms); Logger.Error(string.Format("SendSmsWorker | Trimitere esuata a sms-ului cu id-ul: {0} error: {1}", sms.Id, ex.Message)); } finally { objclsSMS.ClosePort(port); } }