Exemple #1
0
    //團隊報名失敗寄信
    public static void RegistFail_Team(string activity_id, string emp_id, string regist_by, string webPath)
    {
        //andy
        ACMS.VO.ActivatyVO vo = new ACMS.VO.ActivatyVO();
        ACMS.BO.ActivatyBO bo = new ACMS.BO.ActivatyBO();

        string[] smtpto = System.Configuration.ConfigurationManager.AppSettings["SMTPTo"].Split(',');
        Guid id = new Guid(activity_id);
        vo = bo.SelectActivatyByActivatyID(id);
        MailMessage mail = new MailMessage();

        //收件者
        string mailtype = System.Configuration.ConfigurationManager.AppSettings["MailType"].ToLower();
        if ((string.Compare(mailtype, "online") != 0))
        {
            foreach (string st1 in smtpto)
            {
                mail.To.Add(st1);
            }
        }

        else
        {
            EmployeeVO empVO = new EmployeeVO();
            EMPloyeeDAO empDAO = new EMPloyeeDAO();
            if (string.Compare(regist_by, "") != 0)
            {
                empVO = empDAO.getEmployee(regist_by);
                mail.To.Add(empVO.OFFICE_MAIL);
            }
            string[] emps = emp_id.Split(',');

            foreach (string emp in emps)
            {
                if (emp != regist_by)
                {
                    empVO = empDAO.getEmployee(emp);
                    mail.To.Add(empVO.OFFICE_MAIL);
                }
            }

        }
        mail.Subject = vo.activity_name + ":團隊報名失敗通知";
        //寄件者
        mail.From = new System.Net.Mail.MailAddress(System.Configuration.ConfigurationManager.AppSettings["SMTPFrom"], "報名系統通知");
        mail.IsBodyHtml = true;
        mail.Body = "<a href='" + webPath + "?Type=2&ActID="
            + HttpUtility.UrlEncode(activity_id) + "&RegID=" + HttpUtility.UrlEncode(regist_by)
            + "'>" + vo.activity_name + ":團隊報名失敗通知</a>";

        SmtpClient smtp = new SmtpClient(System.Configuration.ConfigurationManager.AppSettings["SMTPServer"]);

        try
        {
            //smtp.Send(mail);

        }
        catch (Exception ex)
        {
            LogMsg.Log(ex.Message, 5, false);

        }
    }
Exemple #2
0
    //個人報名成功寄信
    public static void RegistSuccess(string activity_id, string emp_id, string regist_by, string webPath, string path)
    {
        //andy

        ACMS.VO.ActivatyVO vo = new ACMS.VO.ActivatyVO();
        ACMS.BO.ActivatyBO bo = new ACMS.BO.ActivatyBO();
        string[] smtpto = System.Configuration.ConfigurationManager.AppSettings["SMTPTo"].Split(',');
        Guid id = new Guid(activity_id);
        vo = bo.SelectActivatyByActivatyID(id);

        MailMessage mail = new MailMessage();

        //收件者
        string mailtype = System.Configuration.ConfigurationManager.AppSettings["MailType"].ToLower();

        EmployeeVO empVO = new EmployeeVO();
        EMPloyeeDAO empDAO = new EMPloyeeDAO();
        empVO = empDAO.getEmployee(emp_id);
        ACMS.BO.ActivityRegistBO regBO = new ACMS.BO.ActivityRegistBO();
        ACMS.VO.ActivityRegistVO regVO = regBO.SelectActivityRegistByPK(id, emp_id);

        if ((string.Compare(mailtype, "online") != 0))
        {
            foreach (string st1 in smtpto)
            {
                mail.To.Add(st1);
            }

        }
        else
        {

            mail.To.Add(empVO.OFFICE_MAIL);
            if (emp_id != regist_by)
            {
                empVO = empDAO.getEmployee(regist_by);
                mail.To.Add(empVO.OFFICE_MAIL);
            }
        }

        //取得附加檔案
        ACMS.DAO.UpFilestDAO uDAO = new ACMS.DAO.UpFilestDAO();
        List<ACMS.VO.UpFileVO> listUpfileVo = uDAO.SELECT(path + "\\" + activity_id);
        Attachment data;
        foreach (ACMS.VO.UpFileVO UFvo in listUpfileVo)
        {
            data = new Attachment(UFvo.path);

            mail.Attachments.Add(data);

        }

        mail.Subject = vo.activity_name + ":個人報名成功通知";
        //寄件者
        mail.From = new System.Net.Mail.MailAddress(System.Configuration.ConfigurationManager.AppSettings["SMTPFrom"], "報名系統通知");
        mail.IsBodyHtml = true;

        ACMS.DAO.CustomFieldValueDAO myCustFieldValueDAO = new ACMS.DAO.CustomFieldValueDAO();
        List<ACMS.VO.CustomFieldValueVO> myCustomFieldValueVOList = myCustFieldValueDAO.SelectCustomFieldValue(id, emp_id);
        ACMS.BO.CustomFieldItemBO myCustFieldItemBO = new ACMS.BO.CustomFieldItemBO();
        List<ACMS.VO.CustomFieldItemVO> custFieldItemList;
        string custFieldSt = "";
        decimal ttl = 0;
        string[] FieldIDs;
        #region "自訂欄位"

        foreach (CustomFieldValueVO custFieldVO in myCustomFieldValueVOList)
        {
            if (custFieldVO.field_control.ToLower() == "textbox")
            {
                custFieldSt += "<tr><td>" + "<font color='Blue'><b>." + custFieldVO.field_name + ":</b></font><br/>" + "<font color='black'>  " + custFieldVO.field_value.Trim() + "</font></td></tr>";
            }
            if (custFieldVO.field_control.ToLower() == "textboxlist")
            {
                ttl = 0;
                custFieldSt += "<tr><td>" + "<font color='Blue'><b>." + custFieldVO.field_name + ":</b></font></td></tr>";

                FieldIDs = custFieldVO.field_value.Split(',');
                custFieldItemList = myCustFieldItemBO.SelectByField_id(custFieldVO.field_id);
                custFieldSt += "<tr><td><table>";
                foreach (string fieldID in FieldIDs)
                {
                    foreach (CustomFieldItemVO custFieldItem in custFieldItemList)
                        if (int.Parse(fieldID) == custFieldItem.field_item_id)
                        {
                            custFieldSt += "<tr><td>" + "  " + "<font color='black'>" + custFieldItem.field_item_name + "</font></td><td><font color='black'>$" + custFieldItem.field_item_text + "</font></td></tr>";
                            ttl += decimal.Parse(custFieldItem.field_item_text);
                        }
                }

                custFieldSt += "<tr><td>" + "" + "<font color='Red'>  合計:</font></td><td><font color='Red'>$" + ttl.ToString() + "</font></td></tr>";
                custFieldSt += "</table></td></tr>";

            }
            if (custFieldVO.field_control.ToLower() == "checkboxlist")
            {

                custFieldSt += "<tr><td>" + "<font color='Blue'><b>." + custFieldVO.field_name + ":</b></font></td></tr>";

                FieldIDs = custFieldVO.field_value.Split(',');
                custFieldItemList = myCustFieldItemBO.SelectByField_id(custFieldVO.field_id);
                bool doIt = false;
                foreach (string fieldID in FieldIDs)
                {
                    foreach (CustomFieldItemVO custFieldItem in custFieldItemList)
                        if (int.Parse(fieldID) == custFieldItem.field_item_id)
                        {
                            if (!doIt)
                            {
                                custFieldSt += "";
                            }
                            custFieldSt += "<tr><td><font color='black'>  " + custFieldItem.field_item_name + custFieldItem.field_item_text + "</font></td></tr>";
                            doIt = true;
                        }
                }
               //' custFieldSt = custFieldSt.Substring(0, custFieldSt.Length - 1);
                //custFieldSt += "<br/>";

            }
            if (custFieldVO.field_control.ToLower() == "radiobuttonlist")
            {
                custFieldSt += "<tr><td>" + "<font color='Blue'><b>." + custFieldVO.field_name + "</b>:</font></td></tr>";
                //custFieldSt += "" + "<font color='black'>" + custFieldVO.field_value + "</font>";
                FieldIDs = custFieldVO.field_value.Split(',');
                custFieldItemList = myCustFieldItemBO.SelectByField_id(custFieldVO.field_id);
                foreach (string fieldID in FieldIDs)
                {
                    foreach (CustomFieldItemVO custFieldItem in custFieldItemList)
                        if (int.Parse(fieldID) == custFieldItem.field_item_id)
                        {
                            custFieldSt += "<tr><td>  " + "<font color='black'>" + custFieldItem.field_item_name + custFieldItem.field_item_text + "</font></td></tr>";

                        }
                }
               // custFieldSt += "<br/>";
            }

        }
        #endregion
        ACMS.VO.EmployeeVO regByEmpVO = empDAO.getEmployee(regist_by);
        empVO = empDAO.getEmployee(emp_id);
        if (custFieldSt != "")//有自訂欄位
        {
            mail.Body = "<table border='1' width='400px'><tr><td style='background:#548DD4;Color:White' align='center'  ><b>個人報名成功通知</b></td> </tr><tr><td style ='padding-right :50px;padding-left :50px'>"
                + "<table style='background:White;Color:Black'><tr><td> </td></tr><tr><td> </td></tr><tr><td>" + "<font color='Blue'><b>.姓名:</b></font><font color='black'>" + empVO.NATIVE_NAME + "</font></td></tr><tr><td>"
                + "" + "<font color='Blue'><b>.工號:</b></font><font color='black'>" + empVO.WORK_ID + "</font></td></tr><tr><td>"
                + "" + "<font color='Blue'><b>.活動名稱:</b></font><font color='black'>" + vo.activity_name + "</font></td></tr><tr><td>"
                + "" + "<font color='Blue'><b>.報名日期:</b></font><font color='black'>" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") + "</font></td></tr><tr><td>";

            //   + "" + "<font color='Blue'><b>.工號:</b></font>" + empVO.WORK_ID + "<br/>";
            if (vo.is_showperson_fix2.ToString().ToUpper() == "Y")
            {
                mail.Body += "" + "<font color='Blue'><b>.攜眷人數:</b></font><font color='black'>" + regVO.ext_people.ToString() + "</td></tr><tr><td>";
            }

            mail.Body += "" + "<font color='Blue'><b>" + @"------------------------------------------------------</b></font></td></tr><tr><td> </td></tr><tr><td>";

            mail.Body += "" + "<font color='Blue'><b>以下為此次您報名登入資料,敬請確認:</b></font><br/></td></tr>";

            mail.Body += "" + custFieldSt;
            //如果是他人代理報名,則顯示以下文字
            if (regist_by != emp_id)
            {
                mail.Body += "<tr><td>" + "<font color='Blue'><b>.此活動由</b></font><font color='Black'><u>" + regByEmpVO.NATIVE_NAME + "</u></font><font color='Blue'><b>代理您完成報名</b></font></td></tr>";
            }
            mail.Body += "<tr><td>" + "<font color='Blue'><b>.編號:</b></font><Font color='Red'>" + regBO.getSNByActivity(id, emp_id) + "<br/><br/></font></td></tr></table>" + "<tr><td align='center'> <a href='" + webPath + "?Type=1&ActID="
                + HttpUtility.UrlEncode(activity_id) + "&RegID=" + HttpUtility.UrlEncode(regist_by)
                + "'>" + "報名系統連結</a></td></tr>" + "<tr><td style='background:#548DD4' align='center'  >   &nbsp; </td> </tr></table>";
        }
        else
        {
            mail.Body = "<table border='1' width='400px'><tr><td style='background:#548DD4;Color:White' align='center'  ><b>個人報名成功通知</b></td> </tr><tr><td style ='padding-right :50px;padding-left :50px'>"
                + "<table style='background:White;Color:Black'><tr><td> </td></tr><tr><td> </td></tr><tr><td>" + "<font color='Blue'><b>.姓名:</b></font><font color='black'>" + empVO.NATIVE_NAME + "</font></td></tr><tr><td>"
                + "" + "<font color='Blue'><b>.工號:</b></font><font color='black'>" + empVO.WORK_ID + "</font></td></tr><tr><td>"
                + "" + "<font color='Blue'><b>.活動名稱:</b></font><font color='black'>" + vo.activity_name + "</font></td></tr><tr><td>"
                + "" + "<font color='Blue'><b>.報名日期:</b></font><font color='black'>" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") + "</font></td></tr>";
            //   + "" + "<font color='Blue'><b>.工號:</b></font>" + empVO.WORK_ID + "<br/>";
            if (vo.is_showperson_fix2.ToString().ToUpper() == "Y")
            {
                mail.Body += "<tr><td>" + "<font color='Blue'><b>.攜眷人數:</b></font><font color='black'>" + regVO.ext_people.ToString() + "</font></td></tr>";
            }

            mail.Body += "<tr><td>" + "<font color='Blue'><b>" + @"--------------------------------------------</b></font></td></tr><tr><td> </td></tr><tr><td>";

            mail.Body += "" + "<font color='Blue'><b>以下為此次您報名登入資料,敬請確認:</b></font><br/></td></tr>";

            //如果是他人代理報名,則顯示以下文字
            if (regist_by != emp_id)
            {
                mail.Body += "<tr><td>" + "<font color='Blue'><b>.此活動由</b></font><font color='Black'><u>" + regByEmpVO.NATIVE_NAME + "</u></font><font color='Blue'><b>代理您完成報名</b></font></td></tr>";
            }
            mail.Body += "<tr><td>" + "<font color='Blue'><b>.編號:</b></font><Font color='Red'>" + regBO.getSNByActivity(id, emp_id) + "<br/><br/></font></td></tr></table>" + "<tr><td align='center'> <a href='" + webPath + "?Type=1&ActID="
                + HttpUtility.UrlEncode(activity_id) + "&RegID=" + HttpUtility.UrlEncode(regist_by)
                + "'>" + "報名系統連結</a></td></tr>" + "<tr><td style='background:#548DD4' align='center'  >   &nbsp; </td> </tr></table>";

        }
        SmtpClient smtp = new SmtpClient(System.Configuration.ConfigurationManager.AppSettings["SMTPServer"]);

        string emailAddr = "";
        foreach (MailAddress ma in mail.To)
        {
            emailAddr += ma.Address + ",";
        }
        string ccAddr = "";
        foreach (MailAddress ma1 in mail.CC)
        {
            ccAddr += ma1.Address + ",";
        }

        StringBuilder sb = new StringBuilder();

        sb.AppendLine("Insert  into MailItems( MailFrom, MailTo, MailServer, MailCC, MailSubject, MailBody, Status, Description) values( @MailFrom, @MailTo, @MailServer, @MailCC, @MailSubject, @MailBody, 0,'')");

        SqlParameter[] sqlParams = new SqlParameter[6];
        sqlParams[0] = new SqlParameter("@MailServer", SqlDbType.NVarChar);
        sqlParams[0].Value = System.Configuration.ConfigurationManager.AppSettings["SMTPServer"];
        sqlParams[1] = new SqlParameter("@MailTo", SqlDbType.NVarChar);
        sqlParams[1].Value = emailAddr.TrimEnd(',');
        sqlParams[2] = new SqlParameter("@MailCC", SqlDbType.NVarChar);
        sqlParams[2].Value = ccAddr.TrimEnd(',');
        sqlParams[3] = new SqlParameter("@MailSubject", SqlDbType.NVarChar);
        sqlParams[3].Value = mail.Subject;
        sqlParams[4] = new SqlParameter("@MailBody", SqlDbType.NVarChar);
        sqlParams[4].Value = mail.Body;
        sqlParams[5] = new SqlParameter("@MailFrom", SqlDbType.NVarChar);
        sqlParams[5].Value = System.Configuration.ConfigurationManager.AppSettings["SMTPFrom"];

        SqlConnection myConn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["connStr"].ConnectionString);
        SqlHelper.ExecuteNonQuery(myConn, CommandType.Text, sb.ToString(), sqlParams);

        try
        {
          //  smtp.Send(mail);

        }
        catch (Exception ex)
        {
            LogMsg.Log(ex.Message, 5, false);

        }
    }
Exemple #3
0
    //個人取消報名寄信
    public static void CancelRegist(string activity_id, string emp_id, string cancel_by, string webPath)
    {
        //andy

        ACMS.VO.ActivatyVO vo = new ACMS.VO.ActivatyVO();
        ACMS.BO.ActivatyBO bo = new ACMS.BO.ActivatyBO();
        string[] smtpto = System.Configuration.ConfigurationManager.AppSettings["SMTPTo"].Split(',');
        Guid id = new Guid(activity_id);
        vo = bo.SelectActivatyByActivatyID(id);
        string[] empids = emp_id.Split(',');

        foreach (string st in empids)
        {

            MailMessage mail = new MailMessage();

            //收件者
            string mailtype = System.Configuration.ConfigurationManager.AppSettings["MailType"].ToLower();

            EmployeeVO empVO = new EmployeeVO();
            EmployeeVO empCancelVO = new EmployeeVO();
            EMPloyeeDAO empDAO = new EMPloyeeDAO();

            empVO = empDAO.getEmployee(emp_id);

            if ((string.Compare(mailtype, "online") != 0))
            {
                foreach (string st1 in smtpto)
                {
                    mail.To.Add(st1);
                }
            }
            else
            {
                empVO = empDAO.getEmployee(st);
                mail.To.Add(empVO.OFFICE_MAIL);

                if (st != cancel_by)
                {
                    empVO = empDAO.getEmployee(cancel_by);
                    mail.To.Add(empVO.OFFICE_MAIL);
                }
            }
            empVO = empDAO.getEmployee(st);
            empCancelVO = empDAO.getEmployee(cancel_by);
            mail.Subject = vo.activity_name + ":取消報名通知";
            //寄件者
            mail.From = new System.Net.Mail.MailAddress(System.Configuration.ConfigurationManager.AppSettings["SMTPFrom"], "報名系統通知");
            mail.IsBodyHtml = true;
            mail.Body = "<table border='1'><tr><td style='background:#548DD4;Color:White' align='center'  ><b>取消個人報名通知</b></td> </tr>"
                + "<tr><td style ='padding-right :50px;padding-left :50px'><br/><br/>" + "" + "<b><font color='Blue'>.姓名:</font></b>" + empVO.NATIVE_NAME
                + "<br/>" + "" + "<b><font color='Blue'>.工號:</font></b>" + empVO.WORK_ID
                + "<br/>" + "" + "<b><font color='Blue'>.活動名稱:</font></b>" + vo.activity_name
                + "<br/>" + "" + "<b><font color='Blue'>.取消日期:</font></b>" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss");
            if (cancel_by != emp_id)
            {
                mail.Body += "<br/>" + "" + "<b><font color='Blue'>.此活動由</font></b><font color='black'><u>" + empCancelVO.NATIVE_NAME + "</u></font><font color='Blue'><b>代理您完成取消</b></font>";

            }
            mail.Body += "<br/><br/><br/></td></tr><tr><td align='center'><a href='" + webPath + "?Type=1&ActID="
            + HttpUtility.UrlEncode(activity_id) + "&RegID=" + HttpUtility.UrlEncode(cancel_by)
            + "'>" + "報名系統連結</a><br/></td></tr>" + "<tr><td style='background:#548DD4' align='center'  >  &nbsp;  </td> </tr></table>";

            SmtpClient smtp = new SmtpClient(System.Configuration.ConfigurationManager.AppSettings["SMTPServer"]);
            string emailAddr = "";
            foreach (MailAddress ma in mail.To)
            {
                emailAddr += ma.Address + ",";
            }
            string ccAddr = "";
            foreach (MailAddress ma1 in mail.CC)
            {
                ccAddr += ma1.Address + ",";
            }

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Insert  into MailItems( MailFrom, MailTo, MailServer, MailCC, MailSubject, MailBody, Status, Description) values( @MailFrom, @MailTo, @MailServer, @MailCC, @MailSubject, @MailBody, 0,'')");

            SqlParameter[] sqlParams = new SqlParameter[6];
            sqlParams[0] = new SqlParameter("@MailServer", SqlDbType.NVarChar);
            sqlParams[0].Value = System.Configuration.ConfigurationManager.AppSettings["SMTPServer"];
            sqlParams[1] = new SqlParameter("@MailTo", SqlDbType.NVarChar);
            sqlParams[1].Value = emailAddr.TrimEnd(',');
            sqlParams[2] = new SqlParameter("@MailCC", SqlDbType.NVarChar);
            sqlParams[2].Value = ccAddr.TrimEnd(',');
            sqlParams[3] = new SqlParameter("@MailSubject", SqlDbType.NVarChar);
            sqlParams[3].Value = mail.Subject;
            sqlParams[4] = new SqlParameter("@MailBody", SqlDbType.NVarChar);
            sqlParams[4].Value = mail.Body;
            sqlParams[5] = new SqlParameter("@MailFrom", SqlDbType.NVarChar);
            sqlParams[5].Value = System.Configuration.ConfigurationManager.AppSettings["SMTPFrom"];

            SqlConnection myConn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["connStr"].ConnectionString);
            SqlHelper.ExecuteNonQuery(myConn, CommandType.Text, sb.ToString(), sqlParams);

            try
            {
               // smtp.Send(mail);

            }
            catch (Exception ex)
            {
                LogMsg.Log(ex.Message, 5, false);

            }

        }
    }