Exemple #1
0
        public static string FormatCustomerPersoDataForDownload(List <Customer> customers)
        {
            var customerData = new StringBuilder();

            foreach (Customer customer in customers)
            {
                var _pan = Crypter.Decrypt(System.Configuration.ConfigurationManager.AppSettings.Get("ekey"), customer.Card.CardPan);

                var customerName = FormatCustomerName(customer.Surname, customer.Othernames).ToUpper();
                var today        = System.DateTime.Now;

                customerData.Append("000001");
                customerData.Append("#");
                customerData.Append(PasswordHash.ReFormatPan(_pan));
                customerData.Append("#");
                customerData.Append(String.Format("{0:MM/yy}", today));
                customerData.Append("#");
                customerData.Append(String.Format("{0:MM/yy}", Convert.ToDateTime(customer.Card.CardExpiryDate)));
                customerData.Append("#");
                customerData.Append(customerName.PadRight(25, ' '));
                customerData.Append("#");
                customerData.Append("Wisecard Technology");
                customerData.Append("      ");
                customerData.Append("#");
                customerData.Append(string.Format("478[%B{0}^{1}^{2}201163540000000000478000000? ;{3}={4}2011635447800000?]~389@@", _pan, customerName.PadRight(26, ' '), String.Format("{0:yyMM}", Convert.ToDateTime(customer.Card.CardExpiryDate)), _pan, String.Format("{0:yyMM}", Convert.ToDateTime(customer.Card.CardExpiryDate))));
                customerData.Append("#");
                customerData.Append("100002 7700690073006500630061007200");
                customerData.Append("#");
                customerData.Append(string.Format("{0} 12345 EMV Golden                  ", String.Format("{0:MM/yy}", today)));
                customerData.Append("#");
                customerData.Append("[email protected]           ");
                customerData.Append("#");
                customerData.Append("                                   ");
                customerData.Append("#");
                customerData.Append("                                   ");
                customerData.Append("#");
                customerData.Append("                                   ");
                customerData.Append("#");
                customerData.Append("                              ");
                customerData.Append("#");
                customerData.Append("EUR        5,000");
                customerData.Append("#");
                customerData.Append("EUR        5,000");
                customerData.Append("#");
                customerData.Append(customerName.PadRight(40, ' '));
                customerData.Append("#");
                customerData.Append("EMV Golden                    ");
                customerData.Append("#");
                customerData.Append("EUR        5,000");
                customerData.Append("#");
                customerData.Append("Delivery Branch");
                customerData.Append("     ");
                customerData.Append("#");
                customerData.Append("EUR");
                customerData.Append("#");
                customerData.Append("100");
                customerData.Append("#");
                customerData.Append(" 25");
                customerData.Append("#");
                customerData.Append("100002@@@@@@;5F2D=--");

                if (customers.Count > 1)
                {
                    customerData.AppendLine();
                }
            }

            return(customerData.ToString());
        }
Exemple #2
0
        public static void SendForgotPasswordMail(User user)
        {
            try
            {
                string key = System.Configuration.ConfigurationManager.AppSettings.Get("ekey");
                string encrypted_username = Crypter.Encrypt(key, user.Username);

                string userFullName = user.Lastname + " " + user.Othernames;

                string organization     = System.Configuration.ConfigurationManager.AppSettings.Get("Organization");
                string applicationName  = System.Configuration.ConfigurationManager.AppSettings.Get("ApplicationName");
                string websiteUrl       = System.Configuration.ConfigurationManager.AppSettings.Get("WebsiteUrl");
                string passwordResetUrl = websiteUrl + "User/ResetPassword?rq=" + encrypted_username;;
                string subject          = "Password Reset Request on " + applicationName;

                string fromAddress  = "";
                string smtpUsername = "";
                string smtpPassword = "";
                string smtpHost     = "";
                Int32  smtpPort     = 587;
                bool   smtpUseDefaultCredentials = false;
                bool   smtpEnableSsl             = true;

                MailHelper mailConfig = ConfigurationManager.GetSection("mailHelperSection") as MailHelper;
                if (mailConfig != null && mailConfig.Mail != null)
                {
                    fromAddress  = mailConfig.Mail.FromEmailAddress;
                    smtpUsername = mailConfig.Mail.Username;
                    smtpPassword = mailConfig.Mail.Password;
                }

                if (mailConfig != null && mailConfig.Smtp != null)
                {
                    smtpHost = mailConfig.Smtp.Host;
                    smtpPort = Convert.ToInt32(mailConfig.Smtp.Port);
                    smtpUseDefaultCredentials = Convert.ToBoolean(mailConfig.Smtp.UseDefaultCredentials);
                    smtpEnableSsl             = Convert.ToBoolean(mailConfig.Smtp.EnableSsl);
                }


                string body = "";

                body = System.IO.File.ReadAllText(System.Web.Hosting.HostingEnvironment.MapPath(@"~/App_Data/MailTemplates/ForgotPassword.txt"));
                body = body.Replace("#Organization", organization);
                body = body.Replace("#ApplicationName", applicationName);
                body = body.Replace("#UserFullName", userFullName);
                body = body.Replace("#WebsiteUrl", websiteUrl);
                body = body.Replace("#PasswordResetUrl", passwordResetUrl);

                Thread email = new Thread(delegate()
                {
                    Mail.SendMail(user.Email, fromAddress, subject, body, smtpHost, smtpPort, smtpUseDefaultCredentials, smtpUsername, smtpPassword, smtpEnableSsl);
                });

                email.IsBackground = true;
                email.Start();
            }
            catch (Exception ex)
            {
                ErrorHandler.WriteError(ex);
                throw ex;
            }
        }