List<Tuple<DateTime, bool, string>> m_VBrokerOldReport = new List<Tuple<DateTime, bool, string>>(); // List<> is not thread safe

        #endregion Fields

        #region Methods

        internal void ErrorFromVBrokerOld(object p_commandParams)
        {
            if (!m_persistedState.IsProcessingVBrokerMessagesEnabled)
                return;
            lock (m_VBrokerOldReport)
                m_VBrokerOldReport.Add(new Tuple<DateTime, bool, string>(DateTime.UtcNow, false, p_commandParams as String));

            new SQEmail
            {
                ToAddresses = Encoding.UTF8.GetString(Convert.FromBase64String(ConfigurationManager.ConnectionStrings["HQHealthMonitor.EmailGyantal"].ConnectionString)),
                Subject = "Error From VBrokerOld",
                Body = p_commandParams.ToString(),  // send the command parameter as email body
                IsBodyHtml = false
            }.Send();

            #if !DEBUG_LOCAL_DEVELOPMENT
            TimeSpan timeFromLastCall = DateTime.UtcNow - m_lastVBrokerOldErrorPhoneCallTime;
            if (timeFromLastCall > TimeSpan.FromMinutes(30))
            {
                // 2016-01-12: Twilio usage policy: minimum call duration requirements: 12seconds, so repeat it 3 times.
                var call = new SQPhoneCall { FromNumber = Caller.Gyantal, ToNumber = Caller.Gyantal.AsString(), Message = "Error in Virtual Broker. Please, check your email for details.", NRepeatAll = 3 };
                bool didTwilioAcceptedTheCommand = call.MakeTheCall();
                if (didTwilioAcceptedTheCommand)
                {
                    Utils.Logger.Debug("PhoneCall instruction was sent to Twilio.");
                    m_lastVBrokerOldErrorPhoneCallTime = DateTime.UtcNow;
                }
                else
                    Utils.Logger.Error("PhoneCall instruction was NOT accepted by Twilio.");
            }
            #endif
        }
Esempio n. 2
0
 private void ExecuteCommandTestMakingPhoneCall(object p_commandParams)
 {
     var call = new SQPhoneCall { FromNumber = Caller.Gyantal, ToNumber = Caller.Gyantal.AsString(), Message = "This is a Test Message from the Health Monitor Web Job. Have a nice day.", NRepeatAll = 2 };
     bool didTwilioAcceptedTheCommand = call.MakeTheCall();
     if (didTwilioAcceptedTheCommand)
         Utils.Logger.Debug("PhoneCall instruction was sent to Twilio.");
     else
         Utils.Logger.Error("PhoneCall instruction was NOT accepted by Twilio.");
 }