Esempio n. 1
0
        protected void sendOneAlert(object sender, EventArgs e)
        {
            Button          btn   = (Button)sender;
            List <object[]> data  = new List <object[]>();
            AlertMessenger  aMsgr = new AlertMessenger();

            string truckMsg = getTruckIdentifierMessage(btn);
            string tankMsg  = getTankCapacityMessage(btn);

            try
            {
                int alertID = Convert.ToInt32(btn.CommandArgument);
                EventAlertsHelper eaHelper = new EventAlertsHelper();
                eaHelper.createAndSendAlertEmail(alertID, truckMsg + tankMsg);
                eaHelper.createAndSendAlertSMS(alertID, truckMsg + tankMsg);
            }
            catch (SqlException excep)
            {
                string strErr = " SQLException Error in alertsProcessing sendOneAlert(). Details: " + excep.ToString();
                ErrorLogging.LogErrorAndRedirect(2, strErr);
            }
            catch (Exception ex)
            {
                string strErr = " Exception Error in alertsProcessing sendOneAlert(). Details: " + ex.ToString();
                ErrorLogging.LogErrorAndRedirect(1, strErr);
            }
            finally
            {
            }
        }
        public static void sendEmailWithErrorDetails(string MessageText, EventLogEntryType eventType = EventLogEntryType.Information)
        {
            try
            {
                string ipOfServer = Convert.ToString(HttpContext.Current.Request.Url.Host);
                //System.Net.Dns.GetHostName();
                string         truckReservationEmail = new TruckScheduleConfigurationKeysHelper().truckReservationEmail;
                string         alertEmails           = new TruckScheduleConfigurationKeysHelper().ErrorAlertEmailAddress;
                AlertMessenger aMsgr = new AlertMessenger();
                object         rObj  = null;
                aMsgr._emailAddressesTO.Add(alertEmails);
                //aMsgr._emailAddressesTO.Add("*****@*****.**");
                aMsgr._from    = truckReservationEmail;
                aMsgr._subject = "[Error Logging]- Truck Schedule Application Auto Email";
                aMsgr._body    = "EventLogEntryType " + eventType.ToString() + " found :" + MessageText + " . From address : " + ipOfServer;


                rObj = aMsgr.sendAlertMessage();
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
Esempio n. 3
0
        public static Object testEmail()
        {
            AlertMessenger aMsgr = new AlertMessenger();
            object         rObj  = null;

            aMsgr._emailAddressesTO.Add("*****@*****.**");
            aMsgr._emailAddressesTO.Add("*****@*****.**");
            aMsgr._from    = truckReservationEmail;
            aMsgr._subject = "TEST EMAIL";
            aMsgr._body    = "This is a truck appliction test for sending email.";

            try
            {
                rObj = aMsgr.sendAlertMessage();
            }
            catch (Exception ex)
            {
                string strErr = " Exception Error in alertProcessing testEmail(). Details: " + ex.ToString();
                ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error);
                System.Web.HttpContext.Current.Session["ErrorNum"] = 1;
                ErrorLogging.sendtoErrorPage(1);
            }
            return(rObj);
        }
        public void createAndSendAlertSMS(int alertID, string additionalMsg)
        {
            DataSet dataSet = new DataSet();

            aMsgr = new AlertMessenger();

            try
            {
                using (var scope = new TransactionScope())
                {
                    sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr;

                    dataSet = SqlHelper.ExecuteDataset(sql_connStr, CommandType.StoredProcedure, "sp_truckschedapp_getSMSSubscribersForAlertwAll", new SqlParameter("@pAlertID", alertID));

                    List <string> SentList     = new List <string>();
                    bool          canSendAlert = true;

                    //populate return object
                    foreach (System.Data.DataRow row in dataSet.Tables[0].Rows)
                    {
                        canSendAlert = true;
                        if (SentList.Contains(Convert.ToString(row["SMSemail"])))
                        {
                            canSendAlert = false;
                        }

                        if (canSendAlert == true)
                        {
                            aMsgr._emailAddressesTO.Add(Convert.ToString(row["SMSemail"]));
                            aMsgr._from = TSConfigHelper.truckReservationEmail;

                            aMsgr._subject = Convert.ToString(row["SMSMessageSubject"]);
                            aMsgr._body    = "Default Message: " + Convert.ToString(row["SMSMessageBody"]);
                            aMsgr._body    = (additionalMsg != string.Empty) ? ("Additional Message: " + additionalMsg + aMsgr._body) : aMsgr._body;

                            aMsgr.sendAlertMessage();

                            SentList.Add(Convert.ToString(row["SMSemail"]));
                            aMsgr._emailAddressesTO.Clear();
                        }
                    }
                    scope.Complete();
                }
            }
            catch (SqlException excep)
            {
                string strErr = " SQLException Error in EventAlertsHelper createAndSendAlertSMS(). Details: " + excep.ToString();
                ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error);
                System.Web.HttpContext.Current.Session["ErrorNum"] = 2;
                ErrorLogging.sendtoErrorPage(2);
                throw excep;
            }
            catch (Exception ex)
            {
                string strErr = " Exception Error in EventAlertsHelper createAndSendAlertSMS(). Details: " + ex.ToString();
                ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error);
                System.Web.HttpContext.Current.Session["ErrorNum"] = 1;
                ErrorLogging.sendtoErrorPage(1);
                throw ex;
            }
            finally
            {
            }
        }
 public EventAlertsHelper()
 {
     aMsgr          = new AlertMessenger();
     TSConfigHelper = new TruckScheduleConfigurationKeysHelper();
 }