Beispiel #1
0
        public ReceiptVoucher SaveFailedReceiptVoucher(ReceiptVoucherViewModel receiptVoucher, long transactionId)
        {
            //Insert into failed reciept vouchers only
            try
            {
                using (var paymentMgr = new PaymentManager())
                {
                    return(paymentMgr.SaveFailedReceiptVoucher(receiptVoucher, transactionId));
                }
            }
            catch (Exception ex)
            {
                IExceptionLogger logger = new DefaultExceptionLogger();
                logger.Log("Error", ex);
                return(null);
            }
            finally
            {
                //string ToEmails = ConfigurationManager.AppSettings["PaymentFailureEmails"].ToString();
                SettingStoreBase _storeBase;
                _storeBase = new SettingStoreBase(new LaborServicesDbContext());
                string ToEmails = _storeBase.GetSettingValueByName("PaymentFailureEmails");
                string CCEmail  = "";
                string subject  = "خطأ في إنشاء سند قبض للعميل من علي البورتال";
                string body     = " خطأ في إنشاء سند قبض للعميل رقم ";
                body += receiptVoucher.Customerid;
                body += " من علي البورتال لعقد رقم ";
                body += receiptVoucher.contractid;

                MailSender.SendEmail02(ToEmails, CCEmail, subject, body, false, "");
            }
        }
Beispiel #2
0
        private static bool SendEmail02(string pTo, string ccEmails, string pSubject, string pBody, bool isBodyHTML, Attachment attachment)
        {
            //string Mail = System.Configuration.ConfigurationManager.AppSettings["CSEmail"];
            SettingStoreBase _storeBase;

            _storeBase = new SettingStoreBase(new LaborServicesDbContext());

            string Mail = _storeBase.GetSettingValueByName("CSEmail");

            string MailPass       = GlobalCode.DecryptText(_storeBase.GetSettingValueByName("CSPassword"), "Ahmed");
            string exchangeDomain = System.Configuration.ConfigurationManager.AppSettings["ExchangeDomain"];

            // pTo = "*****@*****.**";
            //ccEmails = "*****@*****.**";
            try
            {
                SmtpClient                  smtpClient      = new SmtpClient();
                NetworkCredential           basicCredential = new NetworkCredential(Mail, MailPass, ExchangeDomain);
                System.Net.Mail.MailMessage message         = new System.Net.Mail.MailMessage();
                message.IsBodyHtml = isBodyHTML;
                MailAddress fromAddress = new MailAddress(Mail);

                // setup up the host, increase the timeout to 5 minutes
                smtpClient.Host = SMTPServer;
                smtpClient.UseDefaultCredentials = false;
                smtpClient.Credentials           = basicCredential;
                smtpClient.Timeout = (60 * 5 * 1000);
                // smtpClient.Port = 587;
                smtpClient.EnableSsl = true;
                message.From         = fromAddress;
                message.Subject      = pSubject + " - " + DateTime.Now.Date.ToString().Split(' ')[0];
                message.IsBodyHtml   = true;
                // message.Body = pBody.Replace("\r\n", "<br>");
                message.Body = pBody;
                string[] to = pTo.Split(';', ',');

                foreach (string mailto in to)
                {
                    if (mailto == "")
                    {
                        continue;
                    }
                    string mailto02 = mailto.Trim(';').Trim(',');
                    if (!string.IsNullOrEmpty(mailto02) && Validator.EmailIsValid(mailto02))
                    {
                        message.To.Add(mailto02);
                    }
                }
                string[] ccs = ccEmails.Split(';', ',');
                for (int i = 0; i < ccs.Length; i++)
                {
                    if (!string.IsNullOrEmpty(ccs[i]) && Validator.EmailIsValid(ccs[i]))
                    {
                        message.CC.Add(ccs[i]);
                    }
                }
                //pTo = pTo.Replace(",", ";");
                //pTo = pTo.Replace(",", ";");
                if (attachment != null)
                {
                    message.Attachments.Add(attachment);
                }
                smtpClient.Send(message);
            }
            catch (Exception ex)
            {
                var logger = log4net.LogManager.GetLogger("FileLogger");
                logger.Error("error", ex);
                throw new ArgumentException(ex.ToString());
            }
            return(true);
        }
 public SettingController()
 {
     _storeBase = new SettingStoreBase(new LaborServicesDbContext());
 }
 public PaymentForMobileController()
 {
     _PaymentTransactionStoreBase = new PaymentTransactionStoreBase(new LaborServicesDbContext());
     _ReceiptVoucherStoreBase     = new ReceiptVoucherStoreBase(new LaborServicesDbContext());
     _storeBase = new SettingStoreBase(new LaborServicesDbContext());
 }
 public PaymentManager()
 {
     _ReceiptVoucherStoreBase     = new ReceiptVoucherStoreBase(new LaborServicesDbContext());
     _PaymentTransactionStoreBase = new PaymentTransactionStoreBase(new LaborServicesDbContext());
     _storeBase = new SettingStoreBase(new LaborServicesDbContext());
 }