Exemple #1
0
        public Task SendAsync(IdentityMessage message)
        {
            var mail = new SmtpEmail();

            mail.Send(message.Destination, message.Subject, message.Body);
            // Plug in your email service here to send an email.

            return(Task.FromResult(0));
        }
Exemple #2
0
        //Send Email Method
        internal static void SendResetEmail(System.Web.Security.MembershipUser user)
        {
            var emailSendModel = new SmtpEmail();


            emailSendModel.Bcc.Add(user.Email);

            emailSendModel.Subject = "Password Reset";
            string link = "http://www.utdbaike.com/Account/ResetPassword/?username="******"&reset=" + HashResetParams(user.UserName, user.ProviderUserKey.ToString());

            emailSendModel.Body  = "<p>" + user.UserName + " please click the following link to reset your password: <a href='" + link + "'>" + link + "</a></p>";
            emailSendModel.Body += "<p>If you did not request a password reset you do not need to take any action.</p>";
            emailSendModel.Send();
        }
        private void SmokeTest()
        {
            int           count = 10;
            List <string> bcc   = new List <string>();

            bcc.Add("*****@*****.**");
            bcc.Add("*****@*****.**");
            bcc.Add("*****@*****.**");
            bcc.Add("*****@*****.**");
            bcc.Add("*****@*****.**");

            while (count-- > 0)
            {
                var emailClient = new SmtpEmail();
                emailClient.Subject = "This is a test";
                emailClient.Body    = "This is a test";
                emailClient.Bcc     = bcc;
                emailClient.Send();
                Thread.Sleep(1000);
            }
        }
    protected void FormView2_ItemInserted(object sender, FormViewInsertedEventArgs e)
    {
        int    li_r2r;
        string ls_cmnts, ls_to, ls_title, ls_val2, ls_val3, ls_val4;

        if (FormView2.DataItemCount > 0)
        {
            DataRowView rowView    = (DataRowView)FormView2.DataItem;
            string      ls_val     = rowView["wrsp_uid"].ToString();
            int         li_respNum = Convert.ToInt32(rowView["wrsp_RespNum"]);
            li_r2r = Convert.ToInt32(rowView["wrsp_RespToResp"]);
            if (li_r2r == null)
            {
                li_r2r = 0;
            }

            WorkOrderBLL WOlogic = new WorkOrderBLL();
            WorkOrder.WorkOrderDataTable WOdt = WOlogic.GetWorkOrdersByWOnumProj(li_wonum, ls_proj);
            DataRow woRow = ((DataRow)(WOdt.Rows[0]));
            ls_title = woRow["word_Title"].ToString();
            if ((User.Identity.Name.Substring(User.Identity.Name.IndexOf("\\") + 1)).ToString() == woRow["word_BusnOwner"].ToString())
            {
                ls_to = woRow["word_BusnOwner"].ToString();
            }
            else
            {
                ls_to = woRow["word_PMorSME"].ToString();
            }

            ls_val2 = woRow["wrsp_Results"].ToString();
            ls_val3 = woRow["wrsp_Consider"].ToString();
            ls_val4 = woRow["wrsp_Risks"].ToString();

            if (string.IsNullOrEmpty(ls_val2))
            {
                ls_val2 = "";
            }
            if (string.IsNullOrEmpty(ls_val3))
            {
                ls_val2 = "";
            }
            if (string.IsNullOrEmpty(ls_val4))
            {
                ls_val2 = "";
            }

            SmtpEmail mailMessage = new SmtpEmail();
            bool      lb_rtn      = mailMessage.Send(User.Identity.Name.Substring(User.Identity.Name.IndexOf("\\") + 1), ls_to, "Work Order Response - " + ls_proj
                                                     + " WO# " + ls_num + " - " + ls_title,
                                                     "WO# " + ls_num + " - " + ls_title + " requires your attention." +
                                                     " Log into the EBS Work Order Module for details. Please do not respond to this email."
                                                     + Environment.NewLine + "http://www.google.com" + Environment.NewLine + Environment.NewLine +
                                                     "The most recent comment on this work order is as follows:" + Environment.NewLine + Environment.NewLine +
                                                     "Results:" + Environment.NewLine + Environment.NewLine + ls_val2 +
                                                     Environment.NewLine + Environment.NewLine + "Considerations:" + Environment.NewLine + Environment.NewLine + ls_val3
                                                     + Environment.NewLine + Environment.NewLine + "Risks:" + Environment.NewLine + Environment.NewLine +
                                                     ls_val4, li_wonum, li_respNum, ls_proj);
        }


        //WorkOrderTableAdapters.WOresponseTableAdapter WOrespAdapter = new WorkOrderTableAdapters.WOresponseTableAdapter();
        //WorkOrder.WOresponseDataTable Responses = WOrespAdapter.GetMaxWOresponseByWOnum(Convert.ToInt32(Request.QueryString["word_WOnum"]),Convert.ToString(Request.QueryString["word_Proj"]));

        //if (Responses.Count > 0)
        //{
        //    FormView2.ChangeMode(FormViewMode.ReadOnly);
        //    woUsersBLL userLogic = new woUsersBLL();
        //    string ls_usr = userLogic.GetFullNameByID(Convert.ToInt32(Responses[0].wrsp_uid));
        //    ((Label)(FormView2.FindControl("UIDlabel"))).Text = ls_usr;
        //}

        FormView2.ChangeMode(FormViewMode.ReadOnly);
    }
Exemple #5
0
        public ActionResult SendSystemEmail(EmailRecord record)
        {
            var    emailModel = new SmtpEmail();
            bool   isSave;
            bool   toNewStudents;
            bool   toFacssVolunteers;
            bool   toPickupVolunteers;
            bool   toHousingVolunteers;
            bool   toAllVolunteers;
            string str = Request["savetorecord"];

            if (str == "on")
            {
                isSave = true;
            }
            else
            {
                isSave = false;
            }

            str = Request["toAllNewStudents"];
            if (str == "on")
            {
                toNewStudents = true;
            }
            else
            {
                toNewStudents = false;
            }
            str = Request["toFacssVolunteers"];
            if (str == "on")
            {
                toFacssVolunteers = true;
            }
            else
            {
                toFacssVolunteers = false;
            }

            str = Request["toPickupVolunteers"];
            if (str == "on")
            {
                toPickupVolunteers = true;
            }
            else
            {
                toPickupVolunteers = false;
            }

            str = Request["toHousingVolunteers"];
            if (str == "on")
            {
                toHousingVolunteers = true;
            }
            else
            {
                toHousingVolunteers = false;
            }

            str = Request["toAllVolunteers"];
            if (str == "on")
            {
                toAllVolunteers = true;
            }
            else
            {
                toAllVolunteers = false;
            }

            record.LastUpdate = DateTime.Now;
            record.Body       = Server.HtmlEncode(record.Body);
            if (isSave)
            {
                web_db.EmailRecords.Add(record);
                web_db.SaveChanges();
            }
            if (toNewStudents)
            {
                var slist = db.NewStudents.ToList();

                foreach (var s in slist)
                {
                    emailModel.Bcc.Add(s.Email);
                }
            }
            if (toAllVolunteers)
            {
                var vlist = db.Volunteers.ToList();
                foreach (var v in vlist)
                {
                    emailModel.Bcc.Add(v.Email);
                }
                var mlist = db.ManualAssignInfoes.ToList();
                foreach (var m in mlist)
                {
                    if (emailModel.Bcc.Contains(m.VolEmail))
                    {
                        continue;
                    }
                    emailModel.Bcc.Add(m.VolEmail);
                }
            }
            else
            {
                if (toFacssVolunteers)
                {
                    var facss = db.Organizations.Where(o => o.Name.Contains("FACSS")).FirstOrDefault();
                    var vlist = facss.Volunteers.ToList();
                    foreach (var v in vlist)
                    {
                        emailModel.Bcc.Add(v.Email);
                    }
                }
                if (toPickupVolunteers)
                {
                    var vlist = db.Volunteers.ToList().Where(v => v.PickupNewStudents != null && v.PickupNewStudents.Count > 0).ToList();
                    foreach (var v in vlist)
                    {
                        emailModel.Bcc.Add(v.Email);
                    }

                    var mlist = db.ManualAssignInfoes.Where(m => m.Type == ManualAssignType.IntPickup).ToList();
                    foreach (var m in mlist)
                    {
                        if (emailModel.Bcc.Contains(m.VolEmail))
                        {
                            continue;
                        }
                        emailModel.Bcc.Add(m.VolEmail);
                    }
                }
                if (toHousingVolunteers)
                {
                    var vlist = db.Volunteers.ToList().Where(v => v.TempHouseNewStudents != null && v.TempHouseNewStudents.Count > 0).ToList();
                    foreach (var v in vlist)
                    {
                        emailModel.Bcc.Add(v.Email);
                    }

                    var mlist = db.ManualAssignInfoes.Where(m => m.Type == ManualAssignType.IntHousing).ToList();
                    foreach (var m in mlist)
                    {
                        if (emailModel.Bcc.Contains(m.VolEmail))
                        {
                            continue;
                        }
                        emailModel.Bcc.Add(m.VolEmail);
                    }
                }
            }
            emailModel.Subject = record.Title;
            emailModel.Body    = Server.HtmlDecode(record.Body);
            emailModel.Send();

            return(Content(emailModel.Count + "emails were sent out successfully!"));
        }
    protected void  btnUpdate_Click(object sender, EventArgs e)
    {
        // First check their LDAP Password . . .
        ldapAuthentication ldapAuth = new ldapAuthentication();

        try
        {
            ldapAuth.AuthenticateUser(User.Identity.Name.Substring(User.Identity.Name.IndexOf("\\") + 1).ToString(), txtBxPassword.Text);
        }
        catch (Exception ex)
        {
            lblText     = Label1.Text;
            Label1.Text = ex.Message.ToString();//"Your LDAP UID and/or password did not authenticate. Please try again.";
            return;
        }

        lblText = Label1.Text;// = "Your LDAP UID and/or password did not authenticate. Please try again.";



        DataView dv = (DataView)ObjectDataSource1.Select();

        //string ls_val;
        //string ls_val2;
        woApprovalBLL apprvLogic = new woApprovalBLL();

        bool lb_rtn = false;

        foreach (DataRow dr in dv.Table.Rows)
        {
            if (Convert.ToInt32(dr["wapr_Approver"]) == Convert.ToInt32(User.Identity.Name.Substring(User.Identity.Name.IndexOf("\\") + 1)))
            {
                int      li_val   = Convert.ToInt32(dr["wapr_AprvNum"]);
                int      li_val1  = li_wonum;
                string   ls_val   = ls_proj;
                DateTime ldt_val  = Convert.ToDateTime(dr["wapr_AprvDate"].ToString());
                int      li_val2  = Convert.ToInt32(dr["wapr_Approver"]);
                bool     lb_val   = chkBxApproval.Checked; //Convert.ToBoolean(dr["wapr_AprvCode"]);
                DateTime ldt_val2 = DateTime.Now;
                string   ls_val2  = txtBxComments.Text;    // dr["wapr_comments"].ToString();
                bool     lb_val2  = Convert.ToBoolean(dr["wapr_required"]);
                bool     lb_val3  = Convert.ToBoolean(dr["wapr_emailFlag"]);

                lb_rtn = apprvLogic.UpdateWOAprvlRecord(li_val, li_val1, ls_val, ldt_val, li_val2, lb_val, ldt_val2, ls_val2, lb_val2, lb_val3, li_val);
                GridView1.DataBind();

                btnUpdate.Visible     = false;
                btnApprove.Visible    = false;
                lnkBtnReturn.Visible  = true;
                Label2.Visible        = false;
                Label3.Visible        = false;
                Label4.Visible        = false;
                Label5.Visible        = false;
                chkBxApproval.Visible = false;
                txtBxPassword.Visible = false;
                txtBxComments.Visible = false;
                txtBxUser.Visible     = false;

                Label1.Text = "Update was successful.";
            }
        }

        WorkOrderBLL woLogic = new WorkOrderBLL();

        WorkOrder.WorkOrderDataTable WrkOrds = woLogic.GetWorkOrdersByWOnumProj(li_wonum, ls_proj);
        WorkOrder.WorkOrderRow       WrkOrd  = WrkOrds[0];

        string    host        = Request.ServerVariables["SERVER_NAME"]; //HttpContext.Current.Request.Url.Host;
        SmtpEmail mailMessage = new SmtpEmail();

        string   ls_to       = "";
        RolesBLL WOroleLogic = new RolesBLL();

        WorkOrder.WOroleTextDisplayDataTable woRoleDT;
        woRoleDT = WOroleLogic.GetWOrolesByWOnumProj(li_wonum, ls_proj);

        foreach (WorkOrder.WOroleTextDisplayRow roleRow in woRoleDT)
        {
            if (Convert.ToBoolean(roleRow["worl_aprvl"]) == true)
            {
                ls_to = ls_to + "," + roleRow["worl_uid"].ToString();
            }
        }

        ldapClient userObject = new ldapClient();
        UserRecord ud;

        ud = userObject.SearchUser(User.Identity.Name.Substring(User.Identity.Name.IndexOf("\\") + 1));

        lb_rtn = mailMessage.Send(User.Identity.Name.Substring(User.Identity.Name.IndexOf("\\") + 1), ls_to, "GO/NoGO ACTION - " + WrkOrd.word_Proj.ToString()
                                  + " WO# " + li_wonum + " - " + WrkOrd.word_Title.ToString(),
                                  "WO# " + li_wonum + " - " + WrkOrd.word_Title.ToString() + " has received a Go/NoGo action from " +
                                  ud.FirstName.ToUpper() + " " + ud.LastName.ToUpper() + "." +
                                  " Log into the EBS Work Order Module for details." +
                                  Environment.NewLine + Environment.NewLine + "http://" + host + "/WorkOrder/EditWO.aspx?word_WOnum=" +
                                  li_wonum.ToString() + "&word_Proj=" + WrkOrd.word_Proj.ToString() + Environment.NewLine + Environment.NewLine +
                                  "The comment left on this Go/NoGo action is as follows:" +
                                  Environment.NewLine + Environment.NewLine +
                                  (Convert.ToBoolean(chkBxApproval.Checked) ? "GO! " : "NO Go! ") + Environment.NewLine + Environment.NewLine +
                                  txtBxComments.Text + Environment.NewLine + Environment.NewLine +
                                  Environment.NewLine + Environment.NewLine + "PLEASE DO NOT RESPOND TO THIS EMAIL!"
                                  , li_wonum, 0, WrkOrd.word_Proj.ToString());
    }
    protected void FormView1_ItemUpdated(object sender, FormViewUpdatedEventArgs e)
    {
        int        statflag;
        int        rws          = e.AffectedRows;
        woPhaseBLL woPhaseLogic = new woPhaseBLL();

        // If Phase changed (or PhaseStat is 'Completed') then a new row is needed in Phase table and WO updated with new Phase/PhaseNumber
        if (!e.NewValues["word_Status"].ToString().Equals(e.OldValues["word_Status"].ToString()) ||
            (!e.NewValues["word_statFlag"].ToString().Equals(e.OldValues["word_statFlag"].ToString()) &&
             e.NewValues["word_statFlag"].ToString().Equals("1")))
        {
            int PhaseNum = woPhaseLogic.InsertPhaseRecord(li_wonum,
                                                          ls_proj, 0, DateTime.Now, e.NewValues["word_Status"].ToString(),
                                                          Convert.ToInt32(e.NewValues["word_statFlag"].ToString()),
                                                          Convert.ToInt32(User.Identity.Name.Substring(User.Identity.Name.IndexOf("\\") + 1)));
        }

        WorkOrderBLL woLogic = new WorkOrderBLL();

        WorkOrder.WorkOrderDataTable WrkOrds = woLogic.GetWorkOrdersByWOnumProj(li_wonum, ls_proj);
        WorkOrder.WorkOrderRow       WrkOrd  = WrkOrds[0];

        //If Phase Status is 'Completed' insert a new row in Phase and update WO with new Phase/Status/PhaseNumber

        if (Convert.ToUInt32(e.NewValues["word_statFlag"]) == 1)
        {
            statflag = 0;
            string NewPhase = "";
            switch (e.NewValues["word_Status"].ToString())
            {
            case "IWOR":
                NewPhase = "WORA";
                break;

            case "WORA":
                NewPhase = "WORD";
                break;

            case "WORM":
                NewPhase = "WORA";
                break;

            case "WORD":
                NewPhase = "WOTS";
                break;

            case "WOTS":
                NewPhase = "WDEV";
                break;

            case "WDEV":
                NewPhase = "WTST";
                break;

            case "WTST":
                NewPhase = "GONG";
                break;

            case "GONG":
                NewPhase = "IMPL";
                break;

            case "IMPL":
                NewPhase = "IMPL";
                statflag = 1;
                break;

            default:

                break;
            }


            int PhaseNum = woPhaseLogic.InsertPhaseRecord(li_wonum,
                                                          ls_proj, 0, DateTime.Now, NewPhase, statflag,
                                                          Convert.ToInt32(User.Identity.Name.Substring(User.Identity.Name.IndexOf("\\") + 1)));


            WrkOrd.word_Status   = NewPhase;
            WrkOrd.word_statFlag = statflag;
            WrkOrd.word_StatNum  = PhaseNum;

            bool lb_rtn;

            lb_rtn = woLogic.UpdateWorkOrder(WrkOrd.word_WOnum, WrkOrd.word_Proj, WrkOrd.word_StatNum,
                                             WrkOrd.word_Status, WrkOrd.word_statFlag, WrkOrd.word_Date, WrkOrd.word_Author,
                                             WrkOrd.word_Title, "", "", WrkOrd.word_Priority,
                                             WrkOrd.word_Descr, WrkOrd.word_Justify, WrkOrd.word_Cmnts, WrkOrd.word_PMorSME,
                                             WrkOrd.word_BusnOwner, WrkOrd.word_reqDueDate, WrkOrd.word_WOnum, WrkOrd.word_Proj);

            string ls_to;
            if (Convert.ToString(User.Identity.Name.Substring(User.Identity.Name.IndexOf("\\") + 1)) == WrkOrd.word_PMorSME.ToString())
            {
                ls_to = WrkOrd.word_BusnOwner.ToString();
            }
            else
            {
                ls_to = WrkOrd.word_PMorSME.ToString();
            }

            string    host        = Request.ServerVariables["SERVER_NAME"]; //HttpContext.Current.Request.Url.Host;
            SmtpEmail mailMessage = new SmtpEmail();

            switch (NewPhase) // This logic makes sure that the authorizers get emails during GO/NoGO phase.
            {
            case "GONG":

                RolesBLL WOroleLogic = new RolesBLL();
                WorkOrder.WOroleTextDisplayDataTable woRoleDT;
                woRoleDT = WOroleLogic.GetWOrolesByWOnumProj(li_wonum, ls_proj);
                //woApprovalBLL apprvLogic = new woApprovalBLL();
                //WorkOrder.WOapprovalDataTable apprvlDT;
                //apprvlDT = apprvLogic.GetWOApprovalDataByWOandProj(li_wonum, ls_proj);

                // this code ensures that every approval record is created
                foreach (WorkOrder.WOroleTextDisplayRow roleRow in woRoleDT)
                {
                    if (Convert.ToBoolean(roleRow["worl_aprvl"]) == true)
                    {
                        ls_to = ls_to + "," + roleRow["worl_uid"].ToString();
                    }
                }



                lb_rtn = mailMessage.Send(User.Identity.Name.Substring(User.Identity.Name.IndexOf("\\") + 1), ls_to, "Work Order Approval - " + WrkOrd.word_Proj.ToString()
                                          + " WO# " + li_wonum + " - " + WrkOrd.word_Title.ToString(),
                                          "WO# " + li_wonum + " - " + WrkOrd.word_Title.ToString() + " requires your Go/NoGo action." +
                                          " Log into the EBS Work Order Module for details. Please do not respond to this email." +
                                          Environment.NewLine + Environment.NewLine + "http://" + host + "/WorkOrder/Approvals.aspx?word_WOnum=" +
                                          li_wonum.ToString() + "&word_Proj=" + WrkOrd.word_Proj.ToString() + Environment.NewLine + Environment.NewLine +
                                          "The most recent comment on this work order is as follows:" +
                                          Environment.NewLine + Environment.NewLine + WrkOrd.word_Cmnts.ToString(), li_wonum, 0, WrkOrd.word_Proj.ToString());

                break;

            default:

                lb_rtn = mailMessage.Send(User.Identity.Name.Substring(User.Identity.Name.IndexOf("\\") + 1), ls_to, "Work Order Modification - " + WrkOrd.word_Proj.ToString()
                                          + " WO# " + li_wonum + " - " + WrkOrd.word_Title.ToString(),
                                          "WO# " + li_wonum + " - " + WrkOrd.word_Title.ToString() + " requires your attention." +
                                          " Log into the EBS Work Order Module for details. Please do not respond to this email." +
                                          Environment.NewLine + Environment.NewLine + "http://" + host + "/WorkOrder/EditWO.aspx?word_WOnum=" +
                                          li_wonum.ToString() + "&word_Proj=" + WrkOrd.word_Proj.ToString() + Environment.NewLine + Environment.NewLine +
                                          "The most recent comment on this work order is as follows:" +
                                          Environment.NewLine + Environment.NewLine + WrkOrd.word_Cmnts.ToString(), li_wonum, 0, WrkOrd.word_Proj.ToString());

                break;
            }
        }

        if (!e.NewValues["word_PMorSME"].ToString().Equals(e.OldValues["word_PMorSME"].ToString()) ||
            !e.NewValues["word_BusnOwner"].ToString().Equals(e.OldValues["word_BusnOwner"].ToString()))
        {
            string ls_to, ls_msg;
            if (Convert.ToString(User.Identity.Name.Substring(User.Identity.Name.IndexOf("\\") + 1)) == WrkOrd.word_PMorSME.ToString())
            {
                ls_to = WrkOrd.word_BusnOwner.ToString();
            }
            else
            {
                ls_to = WrkOrd.word_PMorSME.ToString();
            }

            if (!e.NewValues["word_PMorSME"].ToString().Equals(e.OldValues["word_PMorSME"].ToString()))
            {
                ls_msg = " The Business Owner of this work order has changed.";
            }
            else
            {
                ls_msg = " The Project manager for this work order has changed. ";
            }

            string    host        = Request.ServerVariables["SERVER_NAME"]; //HttpContext.Current.Request.Url.Host;
            SmtpEmail mailMessage = new SmtpEmail();
            bool      lb_rtn      = mailMessage.Send(User.Identity.Name.Substring(User.Identity.Name.IndexOf("\\") + 1), ls_to, "Work Order Modification - " + WrkOrd.word_Proj.ToString()
                                                     + " WO# " + li_wonum + " - " + WrkOrd.word_Title.ToString(),
                                                     "WO# " + li_wonum + " - " + WrkOrd.word_Title.ToString() + " requires your attention." + ls_msg +
                                                     " Log into the EBS Work Order Module for details. Please do not respond to this email."
                                                     + Environment.NewLine + Environment.NewLine + "http://" + host + "/WorkOrder/EditWO.aspx?word_WOnum=" +
                                                     li_wonum.ToString() + "&word_Proj=" + WrkOrd.word_Proj.ToString() + Environment.NewLine + Environment.NewLine + //"http://www.google.com"
                                                     "The most recent comment on this work order is as follows:" +
                                                     Environment.NewLine + Environment.NewLine + WrkOrd.word_Cmnts.ToString(), li_wonum, 0, WrkOrd.word_Proj.ToString());
        }

        Response.Redirect("~/WorkOrder/Default.aspx?word_Proj=" + ls_proj);
    }