public void EncapsulationData()
    {
        EmailObj  = new tblEmail();
        BackupObj = new tblBackup();

        BackupObj.BackupFloder   = txtBackupFolder.Text.Trim();
        BackupObj.BackupDatabase = txtDatabase.Text.Trim();
        BackupObj.BackupServer   = txtServer.Text.Trim();
        BackupObj.BackupID       = System.Guid.NewGuid();

        EmailObj.EmailID      = BackupObj.BackupID;
        EmailObj.SMTPHost     = rtxtServerName.Text.Trim();
        EmailObj.EmailFrom    = rtxtFrom.Text.Trim();
        EmailObj.EmailPort    = Convert.ToInt16(rntxtPort.Text.Trim());
        EmailObj.SMTPUsername = rtxtName.Text.Trim();
        EmailObj.SMTPPassword = rtxtPwd.Text.Trim();
        EmailObj.EmailSSL     = ckbSSL.Checked;

        HttpCookie UserData = Request.Cookies.Get("UserIdCookies");

        if (UserData != null)
        {
            BackupObj.BackupUser = UserData.Value;
        }
        HttpCookie UserPasswordData = Request.Cookies.Get("UserPasswordCookies");

        if (UserPasswordData != null)
        {
            BackupObj.BackupPassword = UserPasswordData.Value;
        }
    }
Exemple #2
0
 public bool InsertEmail(tblEmail email)
 {
     if (email.Sender != "" && email.Email != "" && email.Title != "" && email.Content != "")
     {
         return(_da.InsertEmail(email));
     }
     return(false);
 }
Exemple #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            tblEmail tblEmail = db.tblEmails.Find(id);

            db.tblEmails.Remove(tblEmail);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #4
0
 public ActionResult Edit([Bind(Include = "EmailId,From,To,Message")] tblEmail tblEmail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tblEmail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tblEmail));
 }
Exemple #5
0
 public bool InsertEmail(tblEmail email)
 {
     if (email != null && email.ID != null && !email.ID.Equals(Guid.Empty))
     {
         _dataContext.tblEmails.InsertOnSubmit(email);
         _dataContext.SubmitChanges();
         return(true);
     }
     return(false);
 }
Exemple #6
0
        public ActionResult Create([Bind(Include = "EmailId,From,To,Message")] tblEmail tblEmail)
        {
            if (ModelState.IsValid)
            {
                db.tblEmails.Add(tblEmail);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tblEmail));
        }
Exemple #7
0
 private void SaveEmailDB_Free(int resultID)
 {
     foreach (var email in base.ResultEmailList)
     {
         tblEmail newEmailDB = new tblEmail()
         {
             emailAddress = email,
             resultID     = resultID
         };
         db.tblEmails.Add(newEmailDB);
     }
 }
Exemple #8
0
        public static bool InsertNewUsertoEmailList(tblEmail user)
        {
            var dc     = new AlsiWebDataContext();
            var insert = (!dc.tblEmails.Any(z => z.Email == user.Email));

            if (insert)
            {
                user.Active = true;
                dc.tblEmails.InsertOnSubmit(user);
                dc.SubmitChanges();
                GetEmailList();
            }
            return(insert);
        }
Exemple #9
0
        // GET: Email/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblEmail tblEmail = db.tblEmails.Find(id);

            if (tblEmail == null)
            {
                return(HttpNotFound());
            }
            return(View(tblEmail));
        }
Exemple #10
0
        /// <summary>
        /// 更新对象
        /// </summary>
        /// <param name="EmailObj">需要更新的对象</param>
        /// <returns>返回受影响的行数</returns>
        public virtual string Update(tblEmail EmailObj)
        {
            tblEmail EmailObjUpdate;//需要跟新的对象

            string strMessage = "InsertError";
            int    counts     = 0;//影响行数标记

            try
            {
                ServiceDirectDB = new ServiceDirectDBEntities();
                EmailObjUpdate  = ServiceDirectDB.tblEmail.First(t => t.EmailID == EmailObj.EmailID);
            }catch (EntitySqlException)
            {
                throw;
            }
            catch (EntityException)
            {
                throw;
            }

            //对象进行赋值,准备更新
            EmailObjUpdate.EmailFrom = EmailObj.EmailFrom;
            //EmailObjUpdate.EmailTo = EmailObj.EmailTo;
            EmailObjUpdate.EmailPort = EmailObj.EmailPort;
            EmailObjUpdate.EmailSSL  = EmailObj.EmailSSL;

            EmailObjUpdate.SMTPHost     = EmailObj.SMTPHost;
            EmailObjUpdate.SMTPUsername = EmailObj.SMTPUsername;
            EmailObjUpdate.SMTPPassword = EmailObj.SMTPPassword;

            try
            {
                counts = ServiceDirectDB.SaveChanges();
            }
            catch (EntityException)
            {
                throw;
            }
            if (counts > 0)
            {
                strMessage = "update success";
                return(strMessage);
            }

            return(strMessage);
        }
Exemple #11
0
    public virtual tblEmail HashData()
    {
        tblEmail email = new tblEmail();

        email.newId = Guid.Parse(userId);
        if (!String.IsNullOrEmpty(txtFname.Text))
        {
            email.FirstName = txtFname.Text;
        }
        if (!String.IsNullOrEmpty(txtLname.Text))
        {
            email.LastName = txtLname.Text;
        }
        if (!String.IsNullOrEmpty(txtEmail.Text))
        {
            email.EmailAddress = txtEmail.Text;
        }
        return(email);
    }
Exemple #12
0
        public async Task <ActionResult> ViewEmail(int?EmailID)
        {
            if (Session["user"] != null)
            {
                if (EmailID == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                tblEmail tblEmail = await db.tblEmails.FindAsync(EmailID);

                if (tblEmail.Read == "false")
                {
                    tblEmail.Read = "true";

                    db.Entry(tblEmail).State = EntityState.Modified;
                    await db.SaveChangesAsync();
                }
                return(View(tblEmail));
            }
            return(RedirectToAction("Index", "Home"));
        }
Exemple #13
0
        /// <summary>
        /// 插入的对象
        /// </summary>
        /// <param name="EmailObj">需要插入的对象</param>
        /// <returns>受影响的行数</returns>
        public virtual string Insert(tblEmail EmailObj)
        {
            string strErrorMessage = "InsertError";
            int    counts          = 0;//影响行数标记

            //插入数据
            try
            {
                ServiceDirectDBEntitieAdd = new ServiceDirectDBEntities();
                ServiceDirectDBEntitieAdd.tblEmail.AddObject(EmailObj);
                counts = ServiceDirectDBEntitieAdd.SaveChanges();
            }
            catch (EntitySqlException)
            {
                throw;
            }
            if (counts > 0)
            {
                return(EmailObj.EmailID.ToString());
            }
            return(strErrorMessage);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="ComposeEmail"></param>
        /// <returns></returns>
        public bool SendEmail(ComposeEmail ComposeEmail)
        {
            EmailDomain      EmailDomain   = new EmailDomain();
            tblUser          userfrom      = bringlyEntities.tblUsers.Where(x => x.UserGuid == UserVariables.LoggedInUserGuid).ToList().FirstOrDefault();
            tblEmailTemplate template      = new tblEmailTemplate();
            BusinessObject   tblBusiness   = new BusinessObject();
            string           image         = "<img src = " + CommonDomainLogic.GetCurrentDomain + CommonDomainLogic.GetImagePath(ImageType.Default, "") + ">";
            string           UserImageName = userfrom.ImageName;
            int count = 0;

            if (ComposeEmail.EmailToGuid != null && ComposeEmail.EmailToGuid.Count() > 0)
            {
                foreach (string usertoguid in ComposeEmail.EmailToGuid)
                {
                    tblUser userto = bringlyEntities.tblUsers.Where(x => x.UserGuid == new Guid(usertoguid)).ToList().FirstOrDefault();
                    EmailDomain.EmailTo = userto.EmailAddress;
                    template            = !string.IsNullOrEmpty(ComposeEmail.EmailMessage.TemplateType) ? bringlyEntities.tblEmailTemplates
                                          .Where(x => x.TemplateType == ComposeEmail.EmailMessage.TemplateType).ToList().FirstOrDefault() : new tblEmailTemplate();
                    if (template != null && template.TemplateGuid != null && template.TemplateGuid != Guid.Empty)
                    {
                        EmailDomain.EmailFrom    = userfrom.EmailAddress;
                        EmailDomain.EmailSubject = ComposeEmail.EmailMessage.Subject;
                        if (!ComposeEmail.Isemailreplyorforward)
                        {
                            tblBusiness = bringlyEntities.tblBusinesses.Where(x => x.FK_CreatedByGuid == UserVariables.LoggedInUserGuid).
                                          Select(s => new BusinessObject {
                                BusinessImage = s.BusinessImage, BusinessName = s.BusinessName
                            }).ToList().FirstOrDefault();
                            EmailDomain.EmailBody = template.Body;
                            EmailDomain.EmailBody = EmailDomain.EmailBody.Replace("{ToName}", userto.FullName).Replace("{Description}", ComposeEmail.EmailMessage.Body)
                                                    .Replace("{FromName}", userfrom.FullName);
                        }
                        else
                        {
                            EmailDomain.EmailBody = ComposeEmail.EmailMessage.Body;
                        }

                        string emailSendResult = EmailSender.sendEmail(EmailDomain);
                        if (!string.IsNullOrEmpty(emailSendResult))
                        {
                            ErrorLog.LogError(emailSendResult, "send email Error");
                        }

                        tblEmail tblEmail = new tblEmail();
                        tblEmail.EmailGuid        = Guid.NewGuid();
                        tblEmail.EmailFrom        = EmailDomain.EmailFrom;
                        tblEmail.Subject          = EmailDomain.EmailSubject;
                        tblEmail.Body             = EmailDomain.EmailBody;
                        tblEmail.Sent             = (emailSendResult == "") ? true : false;
                        tblEmail.FK_TemplateGuid  = template.TemplateGuid;
                        tblEmail.DateCreated      = DateTime.Now;
                        tblEmail.FK_CreatedByGuid = UserVariables.LoggedInUserGuid;
                        bringlyEntities.tblEmails.Add(tblEmail);
                        if (tblEmail.Sent)
                        {
                            tblEmailTo tblEmailTo = new tblEmailTo();

                            tblEmailTo.EmailToGuid  = Guid.NewGuid();
                            tblEmailTo.FK_EmailGuid = tblEmail.EmailGuid;
                            tblEmailTo.EmailTo      = EmailDomain.EmailTo;
                            tblEmailTo.FK_UserGuid  = new Guid(usertoguid);// new Guid(usertoguid);
                            bringlyEntities.tblEmailToes.Add(tblEmailTo);
                        }
                        bringlyEntities.SaveChanges();
                        count = count + ((emailSendResult == "") ? 0 : 1);
                    }
                }
            }
            else
            {
                count++;
            }

            if (count > 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Exemple #15
0
        public ActionResult sendEmail()
        {
            string body           = "";
            bool   sendToCustomer = false;
            string emailTo        = "";
            string custEmail      = "";
            string custName       = "";
            string custPhoneNo    = "";
            string emailMessage   = "";
            bool   emailSaved     = false;
            int    count          = 0;

            do
            {
                if (sendToCustomer != true)
                {
                    emailTo   = ConfigurationManager.AppSettings["EmailFormAddress"];
                    custEmail = Request["custEmail"];
                }
                else
                {
                    emailTo   = Request["custEmail"];
                    custEmail = ConfigurationManager.AppSettings["EmailFormAddress"];
                }

                int    smtpPort = Convert.ToInt32(ConfigurationManager.AppSettings["Port"]);
                string username = ConfigurationManager.AppSettings["MailAuthUser"];
                string password = ConfigurationManager.AppSettings["MailAuthPass"];
                custName     = Request["custName"];
                custPhoneNo  = Request["custPhoneNo"];
                emailMessage = Request["emailMessage"];

                if (emailSaved != true)
                {
                    try
                    {
                        tblEmail newEmail = new tblEmail();
                        newEmail.custEmail = custEmail;
                        newEmail.CustName  = custName;
                        newEmail.custPhone = custPhoneNo;
                        newEmail.Subject   = "You have recived a new message from : " + custName;
                        newEmail.Message   = emailMessage;
                        newEmail.Read      = "false";
                        newEmail.DateSent  = DateTime.Now;

                        db.tblEmails.Add(newEmail);
                        db.SaveChanges();

                        emailSaved = true;
                    }
                    catch (Exception)
                    {
                        TempData["error"] = "Email sent but not added to database.";
                    }
                }

                try
                {
                    if (sendToCustomer != true)
                    {
                        using (var sr = new StreamReader(Server.MapPath("//App_Data//emailTemplates/" + "contactEmailNotification.html")))
                        {
                            body = sr.ReadToEnd();
                        }
                    }
                    else
                    {
                        using (var sr = new StreamReader(Server.MapPath("//App_Data//emailTemplates/" + "customerEmailNotification.html")))
                        {
                            body = sr.ReadToEnd();
                        }
                    }

                    MailMessage customerEmailMessage = new MailMessage();
                    customerEmailMessage.To.Add(emailTo);
                    customerEmailMessage.From = new MailAddress(emailTo, "Mobile Hairdresser");
                    customerEmailMessage.ReplyToList.Add(new MailAddress(custEmail));
                    customerEmailMessage.Subject = @"You have recived a new message from : " + custName;
                    if (sendToCustomer != true)
                    {
                        customerEmailMessage.Body = string.Format(body, custName, custPhoneNo, custEmail, emailMessage);
                    }
                    else
                    {
                        customerEmailMessage.Body = string.Format(body, custName, custPhoneNo, emailTo, emailMessage);
                    }

                    customerEmailMessage.IsBodyHtml = true;

                    using (SmtpClient smtp = new SmtpClient())
                    {
                        smtp.EnableSsl             = true;
                        smtp.Host                  = ConfigurationManager.AppSettings["MailServer"];
                        smtp.Port                  = smtpPort;
                        smtp.UseDefaultCredentials = false;
                        smtp.Credentials           = new NetworkCredential(username, password);
                        smtp.DeliveryMethod        = SmtpDeliveryMethod.Network;
                        smtp.SendCompleted        += (s, e) => { smtp.Dispose(); };
                        smtp.Send(customerEmailMessage);
                    }

                    sendToCustomer = true;
                }
                catch (Exception error)
                {
                    TempData["error"] = "An error has occured and your email could not be sent! : " + error;

                    return(RedirectToAction("Contact", "Home"));
                }
                count++;
            } while (count == 1);

            TempData["EmailConfirmation"] = custName;
            return(RedirectToAction("Contact", "Home"));
        }
Exemple #16
0
 partial void DeletetblEmail(tblEmail instance);
Exemple #17
0
 partial void UpdatetblEmail(tblEmail instance);
Exemple #18
0
 partial void InserttblEmail(tblEmail instance);
        /// <summary>
        ///
        /// </summary>
        /// <param name="composeEmail"></param>
        /// <returns></returns>
        public bool SendContactUsMessage(ComposeEmail composeEmail)
        {
            var admin = bringlyEntities.tblUsers
                        .Where(usr => usr.IsActive == true && usr.IsDeleted == false && usr.UserRegistrationType == 3)
                        .Select(usr => usr)
                        .FirstOrDefault();

            EmailDomain emailDomain = new EmailDomain();

            emailDomain.EmailTo   = admin.EmailAddress;
            emailDomain.EmailFrom = composeEmail.EmailMessage.EmailFrom;
            tblEmailTemplate Template = bringlyEntities.tblEmailTemplates.Where(x => x.TemplateType == "ContactUsAdmin").FirstOrDefault();

            if (Template == null)
            {
                return(false);
            }

            emailDomain.EmailSubject = composeEmail.EmailMessage.Subject;
            emailDomain.EmailBody    = Template.Body.Replace("{ToName}", admin.FullName).Replace("{message}", composeEmail.EmailMessage.Body).Replace("{EmailFrom}", composeEmail.EmailMessage.FromName);
            string emailSendResult = EmailSender.sendEmail(emailDomain);

            if (!string.IsNullOrEmpty(emailSendResult))
            {
                ErrorLog.LogError(emailSendResult, "send email Error");
                return(false);
            }
            tblEmail tblEmail = new tblEmail();

            tblEmail.EmailGuid       = Guid.NewGuid();
            tblEmail.EmailFrom       = composeEmail.EmailMessage.EmailFrom;
            tblEmail.Subject         = composeEmail.EmailMessage.Subject;
            tblEmail.Body            = composeEmail.EmailMessage.Body;
            tblEmail.Sent            = (emailSendResult == "") ? true : false;
            tblEmail.FK_TemplateGuid = Template.TemplateGuid;
            tblEmail.DateCreated     = DateTime.Now;
            // tblEmail.FK_CreatedByGuid = UserVariables.LoggedInUserGuid;
            bringlyEntities.tblEmails.Add(tblEmail);
            if (tblEmail.Sent)
            {
                tblEmailTo tblEmailTo = new tblEmailTo();

                tblEmailTo.EmailToGuid  = Guid.NewGuid();
                tblEmailTo.FK_EmailGuid = tblEmail.EmailGuid;
                tblEmailTo.EmailTo      = emailDomain.EmailTo;
                // tblEmailTo.FK_UserGuid = admin.UserGuid;
                bringlyEntities.tblEmailToes.Add(tblEmailTo);
            }
            bringlyEntities.SaveChanges();

            emailDomain           = new EmailDomain();
            emailDomain.EmailTo   = composeEmail.EmailMessage.EmailFrom;
            emailDomain.EmailFrom = admin.EmailAddress;
            Template = bringlyEntities.tblEmailTemplates.Where(x => x.TemplateType == "ContactUsThankYou").FirstOrDefault();

            if (Template == null)
            {
                return(false);
            }

            emailDomain.EmailSubject = Template.Subject;
            emailDomain.EmailBody    = Template.Body.Replace("{ToName}", composeEmail.EmailMessage.FromName);
            emailSendResult          = EmailSender.sendEmail(emailDomain);
            if (!string.IsNullOrEmpty(emailSendResult))
            {
                ErrorLog.LogError(emailSendResult, "send email Error");
                return(false);
            }

            tblEmail                 = new tblEmail();
            tblEmail.EmailGuid       = Guid.NewGuid();
            tblEmail.EmailFrom       = admin.EmailAddress;
            tblEmail.Subject         = emailDomain.EmailSubject;
            tblEmail.Body            = emailDomain.EmailBody;
            tblEmail.Sent            = (emailSendResult == "") ? true : false;
            tblEmail.FK_TemplateGuid = Template.TemplateGuid;
            tblEmail.DateCreated     = DateTime.Now;
            // tblEmail.FK_CreatedByGuid = UserVariables.LoggedInUserGuid;
            bringlyEntities.tblEmails.Add(tblEmail);
            if (tblEmail.Sent)
            {
                tblEmailTo tblEmailTo = new tblEmailTo();

                tblEmailTo.EmailToGuid  = Guid.NewGuid();
                tblEmailTo.FK_EmailGuid = tblEmail.EmailGuid;
                tblEmailTo.EmailTo      = emailDomain.EmailTo;
                //  tblEmailTo.FK_UserGuid = admin.UserGuid;
                bringlyEntities.tblEmailToes.Add(tblEmailTo);
            }
            bringlyEntities.SaveChanges();

            return(true);
        }