Ejemplo n.º 1
0
        static public bool ChainUsesCurrency(string chainName)
        {
            //MGA: 30.08.2010 : Does not work on chains with more than one currency
            // return true;
            int currencies = 0;

            using (SqlConnection connection = new SqlConnection(ReportLibrary.DdDReportState.ChainConnectionString(chainName)))
            {
                connection.Open();
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = connection;
                    cmd.CommandText = String.Format("SELECT distinct currency FROM [{0}].[dbo].[ChainConcernRelation] where chain = (Select id from Chain where name = '{0}')", chainName);
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            ++currencies;
                        }
                    }

                    ETLHelpers.Debug("Currency count for chain " + chainName + " was " + currencies);
                }
            }

            return(currencies > 1);
        }
Ejemplo n.º 2
0
        static public void sendEmail(string to, string header, string body, Attachment attachment)
        {
            ETLHelpers.Debug("Sending email to: {0}", to);
            MailMessage m;

            try
            {
                // m = new MailMessage("*****@*****.**", to);
                m = new MailMessage("*****@*****.**", to);
            }
            catch (Exception e)
            {
                // most likely invalid email
                ETLHelpers.Debug("mail message failed with: " + e.Message);
                return;
            }
            m.Subject = header;
            m.Body    = body;
            if (attachment != null)
            {
                m.Attachments.Add(attachment);
            }
            SmtpClient client = new SmtpClient("pasmtp.tele.dk");

            try
            {
                client.Send(m);
            }
            catch (Exception exception)
            {
                ETLHelpers.error("Could not send email, error {0}", exception.Message);
                ETLHelpers.Debug("Could not send email, error {0}\n{1}", exception.Message, exception.InnerException);
            }
        }