protected void btnTesty_Click(object sender, EventArgs e) { decimal cost = Convert.ToDecimal(SystemVariableDB.GetByDescr("SMSPrice").Value); SMSHistoryDataDB.Insert(1, -1, 62000, "61-nbr...", "msg", cost, txtMsgId.Text); UpdateDB(); }
protected static void SendSMSes(Tuple <int, decimal, string, string, string>[] messagesInfo) { for (int i = 0; i < messagesInfo.Length; i++) { Tuple <int, decimal, string, string, string> messageInfo = (Tuple <int, decimal, string, string, string>)messagesInfo[i]; int bookingID = messageInfo.Item1; decimal cost = messageInfo.Item2; string mobile = messageInfo.Item3; string message = messageInfo.Item4; string callerId = messageInfo.Item5; // until they have an interface to send all in one call, it's better to put each // in its own try/catch block so if some causes an error, it doesn't ruin all of them. try { TransmitSMSAPIWrapper sms = new TransmitSMSAPIWrapper( System.Configuration.ConfigurationManager.AppSettings["SMSTech_Key"], System.Configuration.ConfigurationManager.AppSettings["SMSTech_Secret"], System.Configuration.ConfigurationManager.AppSettings["SMSTech_RequestURL"]); string xmlResponse = sms.MessageSingle(mobile, message, callerId); if (Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["LogSMSSending"])) { Logger.LogSMSSend( System.Web.HttpContext.Current.Session["DB"].ToString() + Environment.NewLine + Environment.NewLine + mobile + Environment.NewLine + Environment.NewLine + message + Environment.NewLine + Environment.NewLine + callerId + Environment.NewLine + Environment.NewLine + xmlResponse, true); } string SMSTechMessageID = GetSMSTechMessageID(xmlResponse); SMSHistoryDataDB.Insert(1, -1, bookingID, mobile, message, cost, SMSTechMessageID); } catch (Exception ex) { Logger.LogSMSSend( mobile + Environment.NewLine + Environment.NewLine + message + Environment.NewLine + Environment.NewLine + cost + Environment.NewLine + Environment.NewLine + callerId + Environment.NewLine + Environment.NewLine + ex.ToString(), true); Logger.LogException(ex, true); } } }