}         // GenerateCodeAndSend

        private void SaveSms(Message twilioResponse)
        {
            EzbobSmsMessage message = EzbobSmsMessage.FromMessage(twilioResponse);

            message.UserId        = null;
            message.UnderwriterId = 1;             //system id
            message.DateSent      = _dateSent;

            try {
                DB.ExecuteNonQuery("SaveSmsMessage", CommandSpecies.StoredProcedure, DB.CreateTableParameter <EzbobSmsMessage>("Tbl", new List <EzbobSmsMessage> {
                    message
                }));
            } catch (Exception ex) {
                Log.Error(ex, "Failed saving twilio SMS send response to DB: {0}", message);
            }

            if (message.Status == null)
            {
                IsError = true;
                Log.Warn("Failed sending SMS to number:{0}", _sendMobilePhone);
                return;
            }             // if

            Log.Info("Sms message sent to '{0}'. Sid:'{1}'", _sendMobilePhone, message.Sid);
        }         // SaveSms
Exemple #2
0
        private void SaveSms(Message smsResponse)
        {
            try {
                var message = EzbobSmsMessage.FromMessage(smsResponse);
                message.UserId        = this.userId;
                message.UnderwriterId = this.underwriterId;
                message.DateSent      = this.dateSent;

                if (smsResponse.RestException != null)
                {
                    string restException = string.Format("RestException Code:{0}, Status:{3}, Message:{1}, MoreInfo:{2}",
                                                         smsResponse.RestException.Code, smsResponse.RestException.Message, smsResponse.RestException.MoreInfo, smsResponse.RestException.Status);
                    Log.Warn("Failed sending SMS to number:{0}\n{1}", this.sendMobilePhone, restException);
                    Result = false;
                    return;
                }

                if (smsResponse.ErrorCode.HasValue || !string.IsNullOrEmpty(smsResponse.ErrorMessage))
                {
                    Log.Warn("Failed sending SMS to number:{0}\n{1} {2}", this.sendMobilePhone, smsResponse.ErrorCode, smsResponse.ErrorMessage);
                    message.Status = smsResponse.ErrorCode + " " + smsResponse.ErrorMessage;
                }

                DB.ExecuteNonQuery("SaveSmsMessage", CommandSpecies.StoredProcedure,
                                   DB.CreateTableParameter <EzbobSmsMessage>("Tbl", new List <EzbobSmsMessage> {
                    message
                }));

                Result = true;
                Log.Info("Sms message sent to '{0}'. Sid:'{1}'", this.sendMobilePhone, message.Sid);
            } catch (Exception ex) {
                Log.Error("Failed saving twilio SMS send response to DB: {0}", ex.Message);
                Result = false;
            }
        }
Exemple #3
0
        }//Execute

        private void HandleOneSms(SMSMessage msg)
        {
            try {
                var senderID = FindSender(msg.From);
                Log.Info("Retrieved income SMS from user: {0} {1} date: {2} body: {3}", senderID, msg.From, msg.DateSent, msg.Body);
                var message = EzbobSmsMessage.FromMessage(msg);
                message.UserId        = senderID;
                message.UnderwriterId = 1;
                SaveToDb(message);
                AddCrm(message);
                AddSalesForceActivity(message);
            } catch (Exception ex) {
                msg = msg ?? new SMSMessage();
                Log.Error(ex, "Failed to retrieve sms {0} {1} {2}", msg.Sid, msg.From, msg.Body);
            }
        }//HandleOneSms