Beispiel #1
0
        public ActionResult CreateUser(WebPlastic.Models.User model)
        {
            ConnectionDataBase.StoreProcediur data = new ConnectionDataBase.StoreProcediur();
            CredencialesDeAcceso access            = new CredencialesDeAcceso();
            string          password   = access.CreatePassword();
            RijndaelManaged myRijndael = new RijndaelManaged();

            myRijndael.GenerateKey();
            myRijndael.GenerateIV();
            string user = access.CreateUserName(model.Name, model.Last).ToLower();

            model.UserName = user;
            Byte[] contrasenaEncriptada = access.EncryptStringToBytes(password, myRijndael.Key, myRijndael.IV);

            DataTable dt  = data.SaveUser(model, contrasenaEncriptada, myRijndael.Key, myRijndael.IV);
            DataRow   row = dt.Rows[0];

            if (dt.Rows.Count > 0)
            {
                SentEmail correoCreacion = new SentEmail();
                string    bodyCorreo     = correoCreacion.EmailForNewUser(model.Name, model.Last, model.UserName, password);
                correoCreacion.SendEmailForNewUser(model.Email, "Creación de Usuario", "*****@*****.**", bodyCorreo, "*****@*****.**", "*****@*****.**", "hola1234", "");
            }

            return(RedirectToAction("Index"));
        }
Beispiel #2
0
        private void sentEmailToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SentEmail SE = new SentEmail();

            SE.Show();
            this.Show();
        }
Beispiel #3
0
        public void Send(string address, string message)
        {
            var email = new SentEmail {
                Address = address, Body = message, Sent = DateTime.Now
            };

            _merloXtraContext.SentEmails.Add(email);
            _merloXtraContext.SaveChanges();
        }
Beispiel #4
0
 public static void Send(string address, string message)
 {
     using (var db = new merloXtra())
     {
         var email = new SentEmail {
             Address = address, Body = message, Sent = DateTime.Now
         };
         db.SentEmails.Add(email);
         db.SaveChanges();
     }
 }
Beispiel #5
0
        public void InsertSentEmail(MailMessage mail)
        {
            SentEmail sentMail = new SentEmail()
            {
                Body     = mail.Body,
                Cc       = mail.CC.ToString(),
                SentDate = DateTime.Now,
                Subject  = mail.Subject,
                To       = mail.To.ToString()
            };

            InsertEntity <SentEmail>(sentMail);
        }
Beispiel #6
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            progressBar1.Value = progressBar1.Value + 5;
            if (progressBar1.Value == 100)
            {
                timer1.Enabled = false;
                progressBar1.Hide();
                usersbll.Username = txtUser.Text;
                usersbll.Password = txtPassword.Text;
                usersbll.UserType = comboBox1.Text.ToString();
                bool success = usersdal.Login(usersbll);
                if (success == true)
                {
                    switch (usersbll.UserType)
                    {
                    case "Admin":
                        this.Hide();
                        AdminPanel ap = new AdminPanel();
                        ap.Show();
                        break;

                    case "Student":
                        this.Hide();
                        AccountPage ap1 = new AccountPage();
                        ap1.Show();
                        break;

                    default:
                        MessageBox.Show("--- Please Select one ---");
                        break;
                    }
                }
                else
                {
                    MessageBox.Show("Wrong ID and Password", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    counter--;
                    if (counter < 0)
                    {
                        SentEmail se = new SentEmail();
                        se.Show();
                    }

                    progressBar1.Value = 0;
                }
            }
        }
Beispiel #7
0
        public IHttpActionResult CreateNewEmail(SentEmail email)
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
            MailMessage mail       = new MailMessage();
            SmtpClient  SmtpServer = new SmtpClient("smtp.gmail.com");

            mail.From = new MailAddress(email.From);
            mail.To.Add(email.RecipientEmail);
            mail.Subject = email.Title;
            mail.Body    = email.Body;

            SmtpServer.Port        = 587;
            SmtpServer.Credentials = new NetworkCredential("*****@*****.**", "theone123456");
            SmtpServer.EnableSsl   = true;

            SmtpServer.Send(mail);

            return(Ok());
        }
Beispiel #8
0
        private SentEmail BuilEmailObject(MessageEntityDto messageDto)
        {
            var obj = new SentEmail();

            obj.Body           = messageDto.MessageDetails;
            obj.Subject        = messageDto.MessageSubject;
            obj.EmailTo        = GetEmailAddress(messageDto.ToMessageDetails);
            obj.CcAddress      = GetEmailAddress(messageDto.CcMessageDetails);
            obj.Status         = 0;
            obj.MailCreateDate = DateTime.Now;
            obj.RefId          = messageDto.MessageId;
            obj.TryCount       = 0;
            obj.SentEmailId    = 0;
            obj.Attachment     = "";
            obj.EmailFrom      = "";
            obj.MailSendDate   = (DateTime?)null;


            return(obj);
        }
Beispiel #9
0
        private async Task SendEmail(ChapterEmailProvider provider, MimeMessage message)
        {
            if (message.To.Count == 0)
            {
                await _loggingService.LogDebug("Not sending email, no recipients set");

                return;
            }

            await _loggingService.LogDebug($"Sending email to {string.Join(", ", message.To)}");

            try
            {
                using SmtpClient client = new SmtpClient
                      {
                          ServerCertificateValidationCallback = (s, c, h, e) => true
                      };
                await client.ConnectAsync(provider.SmtpServer, provider.SmtpPort, SecureSocketOptions.StartTlsWhenAvailable);

                client.Authenticate(provider.SmtpLogin, provider.SmtpPassword);

                await client.SendAsync(message);

                await client.DisconnectAsync(true);

                foreach (InternetAddress to in message.To.Union(message.Cc).Union(message.Bcc))
                {
                    SentEmail sentEmail = new SentEmail(provider.Id, DateTime.UtcNow, to.ToString(), message.Subject);
                    await _emailRepository.AddSentEmail(sentEmail);
                }

                await _loggingService.LogDebug($"Email sent to {string.Join(", ", message.To)}");
            }
            catch (Exception ex)
            {
                await _loggingService.LogError(ex, "Error sending email");

                throw new OdkServiceException("Error sending email");
            }
        }
    protected void SendEmail(int incidentid, int level, int slaid)
    {
        SentEmail objEmail = new SentEmail();

        #region Sent Mail for Level 1 Escalation
        if (level == 1)
        {
            objLevel1 = objLevel1.Get_By_Slaid(slaid);
            if (objLevel1 != null)
            {
                string   varemail    = objLevel1.Emailid;
                string[] arrEmail    = varemail.Split(',');
                int      lengthCount = Convert.ToInt32(arrEmail.Length.ToString());
                for (int i = 0; i < lengthCount - 1; i++)
                {
                    string emailId = arrEmail[i].ToString();
                    if (emailId != "," && emailId != "")
                    {
                        objIncident = objIncident.Get_By_id(incidentid);
                        if (objIncident != null)
                        {
                            objCheckLevel1 = objCheckLevel1.Get_By_id(incidentid);
                            if (objCheckLevel1.Incidentid == 0)
                            {
                                CheckLevel1Escalate obj = new CheckLevel1Escalate();
                                obj.Incidentid     = incidentid;
                                obj.Level1escalate = true;
                                obj.Insert();
                                objEmail.To         = emailId;
                                objEmail.From       = Resources.MessageResource.strEmailFromLevel1Escalate.ToString();
                                objEmail.Subject    = "Problem Not Resolve for Call -" + objIncident.Title;
                                objEmail.Body       = "Dear Sir, The Current Request is not Solved whose Incident Id is " + objIncident.Incidentid + " and Title of Call is " + objIncident.Title + " Thanks & Regards Admin";
                                objEmail.SmtpServer = Resources.MessageResource.strMailServer.ToString();
                                objEmail.SentMail();
                            }
                        }
                    }
                }
            }
        }
        #endregion
        #region Sent Mail for Level 2 Escalation
        if (level == 2)
        {
            objLevel2 = objLevel2.Get_By_Slaid(slaid);
            if (objLevel2.Slaid != 0)
            {
                string   varemail    = objLevel2.Emailid;
                string[] arrEmail    = varemail.Split(',');
                int      lengthCount = Convert.ToInt32(arrEmail.Length.ToString());
                for (int i = 0; i < lengthCount - 1; i++)
                {
                    string emailId = arrEmail[i].ToString();
                    if (emailId != "," && emailId != "")
                    {
                        objIncident = objIncident.Get_By_id(incidentid);
                        if (objIncident != null)
                        {
                            objCheckLevel2 = objCheckLevel2.Get_By_id(incidentid);
                            if (objCheckLevel2.Incidentid == 0)
                            {
                                CheckLevel2Escalate obj = new CheckLevel2Escalate();
                                obj.Incidentid     = incidentid;
                                obj.Level2escalate = true;
                                obj.Insert();
                                objEmail.To         = emailId;
                                objEmail.From       = Resources.MessageResource.strEmailFromLevel2Escalate.ToString();
                                objEmail.Subject    = "Problem Not Resolve for Call -" + objIncident.Title;
                                objEmail.Body       = "Dear Sir, The Current Request is not Solved whose Incident Id is " + objIncident.Incidentid + " and Title of Call is " + objIncident.Title + " Thanks & Regards <br/> Admin";
                                objEmail.SmtpServer = Resources.MessageResource.strMailServer.ToString();
                                objEmail.SentMail();
                            }
                        }
                    }
                }
            }
        }
        #endregion
        #region Sent Mail for Level 3 Escalation
        if (level == 3)
        {
            objLevel3 = objLevel3.Get_By_Slaid(slaid);
            if (objLevel3.Slaid != 0)
            {
                string   varemail    = objLevel3.Emailid;
                string[] arrEmail    = varemail.Split(',');
                int      lengthCount = Convert.ToInt32(arrEmail.Length.ToString());
                for (int i = 0; i < lengthCount - 1; i++)
                {
                    string emailId = arrEmail[i].ToString();
                    if (emailId != "," && emailId != "")
                    {
                        objIncident = objIncident.Get_By_id(incidentid);
                        if (objIncident != null)
                        {
                            objCheckLevel3 = objCheckLevel3.Get_By_id(incidentid);
                            if (objCheckLevel3.Incidentid == 0)
                            {
                                CheckLevel3Escalate obj = new CheckLevel3Escalate();
                                obj.Incidentid     = incidentid;
                                obj.Level3escalate = true;
                                obj.Insert();

                                objEmail.To         = emailId;
                                objEmail.From       = Resources.MessageResource.strEmailFromLevel3Escalate.ToString();
                                objEmail.Subject    = "Problem Not Resolve for Call -" + objIncident.Title;
                                objEmail.Body       = "Dear Sir, The Current Request is not Solved whose Incident Id is " + objIncident.Incidentid + " and Title of Call is " + objIncident.Title + "  Thanks & Regards  Admin";
                                objEmail.SmtpServer = Resources.MessageResource.strMailServer.ToString();
                                objEmail.SentMail();
                            }
                        }
                    }
                }
            }
        }
        #endregion
    }
Beispiel #11
0
 public async Task AddSentEmail(SentEmail sentEmail)
 {
     await Context
     .Insert(sentEmail)
     .ExecuteAsync();
 }
Beispiel #12
0
 /// <summary>
 /// Add Sent Email - Async
 /// </summary>
 /// <param name="sentEmail">SentEmail</param>
 public async Task AddSentEmailAsync(SentEmail sentEmail)
 {
     await DbContext.SentEmails.AddAsync(sentEmail);
 }
    protected void SendEmail(int incidentid, int level,int slaid)
    {
        SentEmail objEmail = new SentEmail();
        #region Sent Mail for Level 1 Escalation
        if (level==1)
          {
            objLevel1 = objLevel1.Get_By_Slaid(slaid);
            if (objLevel1!=null )
            {
                string varemail = objLevel1.Emailid;
                string[] arrEmail = varemail.Split(',');
                int lengthCount = Convert.ToInt16(arrEmail.Length.ToString());
                for (int i = 0; i < lengthCount - 1; i++)
                {
                    string emailId = arrEmail[i].ToString();
                    if (emailId != "," && emailId!="")
                    {
                        objIncident = objIncident.Get_By_id(incidentid);
                        if (objIncident!=null)
                        {

                            objCheckLevel1 = objCheckLevel1.Get_By_id(incidentid);
                            if (objCheckLevel1.Incidentid ==0)
                            {
                                CheckLevel1Escalate obj = new CheckLevel1Escalate();
                                obj.Incidentid = incidentid;
                                obj.Level1escalate = true;
                                obj.Insert();
                                objEmail.To = emailId;
                                objEmail.From = Resources.MessageResource.strEmailFromLevel1Escalate.ToString();
                                objEmail.Subject = "Problem Not Resolve for Call -" + objIncident.Title;
                                objEmail.Body = "Dear Sir, The Current Request is not Solved whose Incident Id is " + objIncident.Incidentid + " and Title of Call is " + objIncident.Title + " Thanks & Regards Admin";
                                objEmail.SmtpServer = Resources.MessageResource.strMailServer.ToString();
                                objEmail.SentMail();
                            }

                        }

                        }

                    }

                }
          }
        #endregion
        #region Sent Mail for Level 2 Escalation
        if (level == 2)
        {
            objLevel2 = objLevel2.Get_By_Slaid(slaid);
            if (objLevel2.Slaid  != 0)
            {
                string varemail = objLevel2.Emailid;
                string[] arrEmail = varemail.Split(',');
                int lengthCount = Convert.ToInt16(arrEmail.Length.ToString());
                for (int i = 0; i < lengthCount - 1; i++)
                {
                    string emailId = arrEmail[i].ToString();
                    if (emailId != "," && emailId != "")
                    {
                        objIncident = objIncident.Get_By_id(incidentid);
                        if (objIncident != null)
                        {

                            objCheckLevel2 = objCheckLevel2.Get_By_id(incidentid);
                            if (objCheckLevel2.Incidentid == 0)
                            {
                                CheckLevel2Escalate obj = new CheckLevel2Escalate();
                                obj.Incidentid = incidentid;
                                obj.Level2escalate = true;
                                obj.Insert();
                                objEmail.To = emailId;
                                objEmail.From = Resources.MessageResource.strEmailFromLevel2Escalate.ToString();
                                objEmail.Subject = "Problem Not Resolve for Call -" + objIncident.Title;
                                objEmail.Body = "Dear Sir, The Current Request is not Solved whose Incident Id is " + objIncident.Incidentid + " and Title of Call is " + objIncident.Title + " Thanks & Regards <br/> Admin";
                                objEmail.SmtpServer = Resources.MessageResource.strMailServer.ToString();
                                objEmail.SentMail();

                            }

                        }

                    }

                }

            }
        }
        #endregion
        #region Sent Mail for Level 3 Escalation
        if (level == 3)
        {
            objLevel3 = objLevel3.Get_By_Slaid(slaid);
            if (objLevel3.Slaid  != 0)
            {
                string varemail = objLevel3.Emailid;
                string[] arrEmail = varemail.Split(',');
                int lengthCount = Convert.ToInt16(arrEmail.Length.ToString());
                for (int i = 0; i < lengthCount - 1; i++)
                {
                    string emailId = arrEmail[i].ToString();
                    if (emailId != "," && emailId != "")
                    {
                        objIncident = objIncident.Get_By_id(incidentid);
                        if (objIncident != null)
                        {

                            objCheckLevel3 = objCheckLevel3.Get_By_id(incidentid);
                            if (objCheckLevel3.Incidentid == 0)
                            {
                                CheckLevel3Escalate obj = new CheckLevel3Escalate();
                                obj.Incidentid = incidentid;
                                obj.Level3escalate = true;
                                obj.Insert();

                                objEmail.To = emailId;
                                objEmail.From = Resources.MessageResource.strEmailFromLevel3Escalate.ToString();
                                objEmail.Subject = "Problem Not Resolve for Call -" + objIncident.Title;
                                objEmail.Body = "Dear Sir, The Current Request is not Solved whose Incident Id is " + objIncident.Incidentid + " and Title of Call is " + objIncident.Title + "  Thanks & Regards  Admin";
                                objEmail.SmtpServer = Resources.MessageResource.strMailServer.ToString();
                                objEmail.SentMail();

                            }

                        }

                    }

                }

            }
        }
        #endregion
    }
Beispiel #14
0
        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            SentEmail em = new SentEmail();

            em.Show();
        }
        /// <summary>
        /// Add Payment - Async
        /// </summary>
        /// <param name="paymentViewModel">New PaymentViewModel</param>
        /// <returns>Added Payment</returns>
        public async Task <PaymentViewModel> AddPaymentViewModelAsync(PaymentViewModel paymentViewModel)
        {
            using (IDbContextTransaction transaction = await UnitOfWork.BeginTransactionAsync())
            {
                try
                {
                    // need change
                    // Here we need to check the payment referenece from their api

                    string username = HttpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;

                    User user = await UnitOfWork.UserRepository.GetUserByUsernameAsync(username);

                    if (user == null)
                    {
                        throw new Exception("Invalid user or user not found.");
                    }

                    PaymentMethod paymentMethod = await UnitOfWork.PaymentMethodRepository.GetPaymentMethodByCodeAsync(paymentViewModel.PaymentMethodCode);

                    if (paymentMethod == null)
                    {
                        throw new Exception("Invalid payment method code.");
                    }

                    Payment payment = Mapper.Map <PaymentViewModel, Payment>(paymentViewModel);

                    // Set Payment's missing parts
                    payment.UserId          = user.Id;
                    payment.PaymentMethodId = paymentMethod.Id;

                    await UnitOfWork.PaymentRepository.AddPaymentAsync(payment);

                    //Update user's loyalty points
                    user.LoyaltyPoints += payment.EarnedLoyaltyPoints;

                    string message = $"{ ((user.Gender == Gender.Male) ? "Mr" : "Miss/ Mrs") }. { user.FirstName }, you payed Rs.{ string.Format("{0:0.00}", payment.Amount) } successfully by { paymentMethod.Name } on { payment.PayedDateTime }";

                    SentEmail sentEmail = new SentEmail()
                    {
                        Subject = "Payment success",
                        Message = message,
                        Payment = payment,
                        UserId  = user.Id
                    };
                    //Do what ever thing in here to send email
                    await UnitOfWork.SentEmailRepository.AddSentEmailAsync(sentEmail);

                    SentMessage sentMessage = new SentMessage()
                    {
                        Message = message,
                        Payment = payment,
                        UserId  = user.Id
                    };
                    //Do what ever thing in here to send sms
                    await UnitOfWork.SentMessageRepository.AddSentMessageAsync(sentMessage);

                    await UnitOfWork.CompleteAsync();

                    transaction.Commit();

                    payment.PaymentMethod = paymentMethod;

                    // Create new Payment ViewModel
                    PaymentViewModel addedPaymentViewModel = Mapper.Map <Payment, PaymentViewModel>(payment);
                    addedPaymentViewModel.PaymentMethodCode = paymentMethod.Code;

                    return(addedPaymentViewModel);
                }
                catch
                {
                    transaction.Rollback();
                    throw;
                }
            }
        }
Beispiel #16
0
        public IEnumerable<MailerResult> SendMailToGroup(int emailId, int groupId)
        {
            IRepository<Email> emailRepo = UnitOfWork.Repository<Email>();
            IRepository<GroupSubscription> groupSubscriptionsRepo = UnitOfWork.Repository<GroupSubscription>();

            Email emailToSend = emailRepo.FindById(emailId);
            List<GroupSubscription> groupSubscribers = groupSubscriptionsRepo.Query
                .Where(gs => gs.GroupId == groupId &&
                             !gs.DateLeft.HasValue)
                .Include(gs => gs.Subscriber)
                .ToList();

            // if email not found or no subscribers to send to, return null
            if (emailToSend == null || groupSubscribers.Count == 0)
            {
                return new[] { new MailerResult(MailerResultStatusEnum.Exception, "Invalid Id's specified!", null) };
            }

            List<MailPigEmail> emailsToDeliver = groupSubscribers
                .Select(gs => new MailPigEmail(
                    emailId,
                    gs.Id,
                    SenderEmail,
                    gs.Subscriber.Email,
                    emailToSend.Subject,
                    emailToSend.Body))
                .ToList();

            Mailer mailer = new Mailer();
            IEnumerable<MailerResult> results = mailer.SendBulk(emailsToDeliver);

            IRepository<SentEmail> sentEmailsRepo = UnitOfWork.Repository<SentEmail>();
            foreach (MailPigEmail mailPigEmail in emailsToDeliver)
            {
                if (mailPigEmail.SentSuccessfully)
                {
                    SentEmail sentMail = new SentEmail
                    {
                        DateSent = DateTime.Now,
                        EmailId = mailPigEmail.EmailId,
                        RecipientId = mailPigEmail.RecipientId
                    };
                    sentEmailsRepo.Insert(sentMail);
                }
            }

            return results.ToList();
        }