Beispiel #1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                string title = txtTitle.Text.Trim();
                int EmailFromSeleccted = Convert.ToInt16(cbEmailList.SelectedIndex);

                // Format noi dung
                string content = txtContent.Value;

                string templateDir = HttpContext.Current.Server.MapPath("/Tools/Mail");
                string templateName = "Content.html";

                INVelocityEngine fileEngine = NVelocityEngineFactory.CreateNVelocityFileEngine(templateDir, true);

                List<Model.Newsletter> EmailList = bll.GetList(-1, "", -1, 1, 1000000);

                if (EmailList.Any())
                {
                    List<Model.EmailOut> EmailOutList = new List<EmailOut>();

                    foreach (var item in EmailList)
                    {
                        Model.EmailOut model = new Model.EmailOut();

                        model.EmailTo = item.Email;
                        model.EmailSubject = title;
                        model.Status = 0;

                        IDictionary dic = new Hashtable();
                        dic.Add("EMAIL", item.Email);
                        dic.Add("TITLE", title);
                        dic.Add("CONTENT", content);
                        string EmailBody = fileEngine.Process(dic, templateName);

                        model.EmailBody = EmailBody;

                        EmailOutList.Add(model);
                    }

                    Common.EMailAsync.Instance.PushEMail(EmailOutList, EmailFromSeleccted, "System");

                    JscriptMsg("Đã gởi thành công !", "MailOut.aspx", "Success");
                }
            }
            catch (Exception ex)
            {
                JscriptMsg(ex.Message, "", "Error");
            }
        }
Beispiel #2
0
        private void ForGotPassword()
        {
            string password = string.Empty;
            string truePassword =string.Empty;
            string memberName = string.Empty;
            string email = Request["email"].ToString();

            BLL.Member.Instance.Member_Get_Password(email,ref memberName, ref password);

            if (password == string.Empty)
            {
                Response.Write("1|Không tìm thấy tài khoản trên hệ thống.");
            }
            else
            {
                //gui mail
                truePassword = Common.DESEncrypt.Decrypt(password);

                // Thanh vien su dung goi dich vu
                string templateDir = HttpContext.Current.Server.MapPath("/Tools/Mail");
                string templateName = "ForgotPassword.html";

                INVelocityEngine fileEngine = NVelocityEngineFactory.CreateNVelocityFileEngine(templateDir, true);

                IDictionary dic = new Hashtable();
                dic.Add("MEMBER_NAME", memberName);
                dic.Add("PASSWORD", truePassword);

                Model.EmailOut eo = new Model.EmailOut();
                eo.EmailSubject = "Thông báo mật khẩu";
                eo.EmailBody = fileEngine.Process(dic, templateName);
                eo.EmailTo = email;
                List<Model.EmailOut> lst = new List<Model.EmailOut>();
                lst.Add(eo);
                EMailAsync.Instance.PushEMail(lst, 0, "SYSTEM");
            }
            Response.Write("0|Chúng tôi đã email mật khẩu vào hộp thư bạn cung cấp.");
            Response.End();
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Model.Member model = new Model.Member();

            DateTime dt_NgaySinh;

            if (!(String.IsNullOrEmpty(ddlday.SelectedValue.ToString())) && !(String.IsNullOrEmpty(ddlMonth.SelectedValue.ToString())) && !(String.IsNullOrEmpty(ddlYear.SelectedValue.ToString())))
            {
                dt_NgaySinh = new DateTime(Convert.ToInt32(ddlYear.SelectedValue), Convert.ToInt32(ddlMonth.SelectedValue), Convert.ToInt32(ddlday.SelectedValue));
            }
            else
            {
                return;
            }
            if (txtMatKhau.Text.Trim() != txtXNMatKhau.Text.Trim())
            {
                return;
            }

            Int32 PackageID = Convert.ToInt32(cbPackageID.Value);

            string msgCode = string.Empty;
            int ErrCode = 0;
            int txtMemberID = 0;
            int paymentType = Convert.ToInt16(cbPaymentType.SelectedValue);

            string memberCode = string.Empty;
            int unitPrice = 0;
            string packageName = string.Empty;

            Boolean isBookBuy = false;
            HttpClient client = new HttpClient();
            client.BaseAddress = new Uri("http://bookbuy.vn/");
            string membberBookBuyEmail = bookbuyEmail.Text;
            string memberBookBuyPassword = bookbuyPassword.Text;

            if (membberBookBuyEmail != null && !membberBookBuyEmail.Equals(""))
            {
                if (memberBookBuyPassword == null || memberBookBuyPassword.Equals(""))
                {
                    msgCode = "Tài khoản BookBuy không chính xác";
                    ErrCode = -1;
                    ShowModal(msgCode, ErrCode);
                    return;
                }
                var content = new FormUrlEncodedContent(new[]
            {
                new KeyValuePair<string, string>("username", membberBookBuyEmail),
                new KeyValuePair<string, string>("password", memberBookBuyPassword)
            });

                var response = client.PostAsync("api/iBookStopApi/iBookStopCollection", content).Result;
                if (response.IsSuccessStatusCode)
                {
                    BookbuyResponse bookbuyResponse = response.Content.ReadAsAsync<BookbuyResponse>().Result;
                    if (!bookbuyResponse.Success)
                    {
                        msgCode = "Tài khoản BookBuy không chính xác";
                        ErrCode = -1;
                        ShowModal(msgCode, ErrCode);
                        return;
                    }
                    else
                    {
                        isBookBuy = true;
                    }

                }
            }

            bll.MemberRegistry(ref txtMemberID,
                                    txtHoten.Text,
                                    txtCMND.Text,
                                    dt_NgaySinh,
                                    rbGtinh.SelectedItem.Text,
                                    txtDiachi.Text, "",
                                    txtSoDienThoai.Text, "",
                                    txtEmail.Text,
                                    isBookBuy ? membberBookBuyEmail : "",
                                    txtMatKhau.Text,
                                    txtSoTaiKhoan.Text,
                                    txtNganhang.Text.Trim(),
                                    txtNNghiep.Text,
                                    "", "", "", 0, false, "", "",
                                    "", "", "", PackageID, paymentType,ref memberCode,ref unitPrice, ref packageName, ref ErrCode);

            switch (ErrCode)
            {
                case 3:
                    msgCode = "Email đã được dùng đăng ký";
                    break;
                case 31:
                    msgCode = "Email BookBuy đã được dùng đăng ký";
                    break;
                case 150:
                    msgCode = "Email đã được dùng đăng ký";
                    break;
                default:
                    if (PackageID > 0)
                    {
                        // Thanh vien su dung goi dich vu
                        string templateDir = HttpContext.Current.Server.MapPath("/Tools/Mail");
                        string templateName = "RegPackage.html";

                        INVelocityEngine fileEngine = NVelocityEngineFactory.CreateNVelocityFileEngine(templateDir, true);

                        IDictionary dic = new Hashtable();
                        dic.Add("SEND_DATE", DateTime.Now.ToString("dd/MM/yyyy"));
                        dic.Add("MEMBER_ID", memberCode);
                        dic.Add("MEMBER_NAME", txtHoten.Text);
                        dic.Add("PACKAGE_NAME", packageName);
                        dic.Add("PACKAGE_VALUE", unitPrice);

                        Model.EmailOut eo = new Model.EmailOut();
                        eo.EmailSubject = "Thông báo đăng ký tài khoản";
                        eo.EmailBody = fileEngine.Process(dic, templateName);
                        eo.EmailTo = txtEmail.Text.Trim();
                        List<Model.EmailOut> lst = new List<Model.EmailOut>();
                        lst.Add(eo);
                        EMailAsync.Instance.PushEMail(lst, 0, "SYSTEM");
                    }
                    else
                    {
                        // Thanh vien khong su dung goi dich vu
                        string templateDir = HttpContext.Current.Server.MapPath("/Tools/Mail");
                        string templateName = "RegNoPackage.html";

                        INVelocityEngine fileEngine = NVelocityEngineFactory.CreateNVelocityFileEngine(templateDir, true);

                        IDictionary dic = new Hashtable();
                        dic.Add("SEND_DATE", DateTime.Now.ToString("dd/MM/yyyy"));
                        dic.Add("MEMBER_ID", memberCode);
                        dic.Add("MEMBER_NAME", txtHoten.Text);

                        Model.EmailOut eo = new Model.EmailOut();
                        eo.EmailSubject = "Thông báo đăng ký tài khoản";
                        eo.EmailBody = fileEngine.Process(dic, templateName);
                        eo.EmailTo = txtEmail.Text.Trim();
                        List<Model.EmailOut> lst = new List<Model.EmailOut>();
                        lst.Add(eo);
                        EMailAsync.Instance.PushEMail(lst, 0, "SYSTEM");
                    }
                    msgCode = "Đăng ký thành công, bạn có thể đăng nhập vào hệ thống bằng tài khoản vừa tạo. Vui lòng kiểm tra hộp thư hoặc trong thư mục spam !";
                    break;
            }

            ShowModal(msgCode, ErrCode);
        }
Beispiel #4
0
        public List<Model.EmailOut> GetList(Int64 _Id, string _EmailFrom, string _EmailTo, string _EmailSubject, int _Status, int _Start, int _Limit)
        {
            List<Model.EmailOut> result = new List<Model.EmailOut>();

            try
            {

                SqlParameter[] p =  {
                                        new SqlParameter("@Id", SqlDbType.Int, 4),
                                        new SqlParameter("@EmailFrom", SqlDbType.NVarChar, 250),
                                        new SqlParameter("@EmailTo", SqlDbType.NVarChar, 250),
                                        new SqlParameter("@EmailSubject", SqlDbType.NVarChar, 250),
                                        new SqlParameter("@Status", SqlDbType.Int, 4),
                                        new SqlParameter("@Start", SqlDbType.Int, 4),
                                        new SqlParameter("@Limit", SqlDbType.Int, 4)
                                    };

                p[0].Value = _Id;
                p[1].Value = _EmailFrom;
                p[2].Value = _EmailTo;
                p[3].Value = _EmailSubject;
                p[4].Value = _Status;
                p[5].Value = _Start;
                p[6].Value = _Limit;

                DataTable dt = db.ExcuteSelectReturnDataTable("EmailOut_Select", CommandType.StoredProcedure, p);

                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        Model.EmailOut model = new Model.EmailOut();

                        model.Ind = Convert.ToInt32(dr["Ind"]);
                        model.Id = Convert.ToInt32(dr["Id"]);
                        model.EmailFrom = dr["EmailFrom"].ToString();
                        model.EmailTo = dr["EmailTo"].ToString();
                        model.EmailSubject = dr["EmailSubject"].ToString();
                        model.EmailBody = dr["EmailBody"].ToString();
                        model.Status = Convert.ToInt32(dr["Status"]);
                        model.StatusText = dr["StatusText"].ToString();
                        model.Exception = dr["Exception"].ToString();
                        model.CreateBy = dr["CreateBy"].ToString();
                        model.CreateTime = dr["CreateTime"].ToString();
                        model.UpdateBy = dr["UpdateBy"].ToString();
                        model.UpdateTime = dr["UpdateTime"].ToString();
                        model.TotalRow = Convert.ToInt32(dr["TotalRow"]);

                        result.Add(model);
                    }

                }

            }
            catch (Exception ex)
            {
                PTSLog.Error(ex.Message);
            }

            return result;
        }
        private void MemberRegPackage(HttpContext context)
        {
            string result = string.Empty;
            Int32 memberId = Convert.ToInt32(context.Request["id"]);
            Int32 packageId = Convert.ToInt32(context.Request["package"]);

            string MemberCode = string.Empty;
            string MemberName = string.Empty;
            string MemberEmail = string.Empty;
            string PackageName = string.Empty;
            int UnitPrice = 0;
            int _ErrCode = 0;

            if (memberId > 0 && packageId > 0)
            {
                BLL.Member bll = BLL.Member.Instance;

                bll.Member_Register_Use_Package(memberId, packageId, ref MemberCode, ref MemberName, ref PackageName, ref UnitPrice, ref MemberEmail, ref _ErrCode);

                if (!string.IsNullOrEmpty(MemberEmail))
                {
                    string templateDir = HttpContext.Current.Server.MapPath("/Tools/Mail");
                    string templateName = "RegPackage.html";

                    INVelocityEngine fileEngine = NVelocityEngineFactory.CreateNVelocityFileEngine(templateDir, true);

                    IDictionary dic = new Hashtable();
                    dic.Add("MEMBER_ID", MemberCode);
                    dic.Add("MEMBER_NAME ", MemberName);
                    dic.Add("PACKAGE_NAME ", PackageName);
                    dic.Add("PACKAGE_VALUE ", UnitPrice);

                    Model.EmailOut eo = new Model.EmailOut();
                    eo.EmailSubject = "Thông báo kích hoạt tài khoản";
                    eo.EmailBody = fileEngine.Process(dic, templateName);
                    eo.EmailTo = MemberEmail;
                    List<Model.EmailOut> lst = new List<Model.EmailOut>();
                    lst.Add(eo);
                    EMailAsync.Instance.PushEMail(lst, 0, "SYSTEM");
                }

                if (_ErrCode == 0)
                {
                    result = "Chúc mừng bạn đã đăng ký thành công gói dịch vụ !";
                }
                else
                {
                    result = "Lỗi xảy ra, vui lòng nhấn F5 thử lại !";
                }
            }
            else
            {
                result = "Lỗi xảy ra, vui lòng nhấn F5 thử lại !";
            }

            Hashtable tb = new Hashtable();
            tb.Add("code", _ErrCode);
            tb.Add("msg", result);

            var json = JsonConvert.SerializeObject(tb);
            context.Response.Write(json);
        }
Beispiel #6
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (_MemberID <= 0)
            {
                JscriptMsg("Lỗi xảy ra: " + "Không lấy được thông tin thành viên", "", "Error");
                return;
            }

            string _ApproveBy = string.Empty;

            if (Utils.GetCookie(PTSKeys.ADMIN_NAME, PTSKeys.CDL_CMS_KEY) != null)
            {
                _ApproveBy = Utils.GetCookie(PTSKeys.ADMIN_NAME, PTSKeys.CDL_CMS_KEY);

            }

            int _UsePackageID = int.Parse(txtUsePackageID.Text.Trim());

            int _StatusPackage = int.Parse(ddlStatusPackage.SelectedValue.ToString());

            int _StatusMember = int.Parse(ddlStatusMember.SelectedValue.ToString());

            int _error_code = 0;

            if (_UsePackageID == 0) {

                JscriptMsg("Thành viên chưa sử dụng gói dịch vụ nào", "", "Success");
                return;
            }

            bll.Member_UsePackage_Process(_MemberID,_UsePackageID,_StatusPackage,_StatusMember, _ApproveBy, ref _error_code);

            //kich hoat tai khoan
            if (_StatusPackage == 1) {

                DataTable dt = bll.Member_Email_Active_Package(_UsePackageID);

                string templateDir = HttpContext.Current.Server.MapPath("/Tools/Mail");
                string templateName = "package_active.html";

                INVelocityEngine fileEngine = NVelocityEngineFactory.CreateNVelocityFileEngine(templateDir, true);

                //DataTable dtmem = bll.MEMBER_EMAIL_ACTIVE_PACKAGE((long)_UsePackageID);

                IDictionary dic = new Hashtable();
                dic.Add("SEND_DATE",DateTime.Now.ToString("dd/MM/yyyy"));
                dic.Add("MEMBER_NAME", dt.Rows[0]["MemberName"].ToString());
                dic.Add("MEMBER_ID", _MemberID.ToString());
                dic.Add("PACKAGE_NAME", dt.Rows[0]["PackageName"].ToString());
                dic.Add("PACKAGE_VALUE", dt.Rows[0]["PackageValue"].ToString());

                dic.Add("EXTEND_COUNT", dt.Rows[0]["MaxTryOrder"].ToString());
                dic.Add("MAXBOOK_AMOUNT", dt.Rows[0]["MaxBorrowBook"].ToString());
                dic.Add("EXPIRED_DATE", dt.Rows[0]["ExpiredDate"].ToString());
                dic.Add("EMAIL", dt.Rows[0]["Email"].ToString());

                dic.Add("PASSWORD",  DESEncrypt.Decrypt(dt.Rows[0]["Password"].ToString()));

                Model.EmailOut eo = new Model.EmailOut();
                eo.EmailSubject = "Thông báo kích hoạt tài khoản";
                eo.EmailBody = fileEngine.Process(dic, templateName);
                eo.EmailTo = dt.Rows[0]["Email"].ToString();
                List<Model.EmailOut> lst = new List<Model.EmailOut>();
                lst.Add(eo);
                EMailAsync.Instance.PushEMail(lst, 0, _ApproveBy);

                //string MailSubject = "Bảng báo giá chi tiết";
                //string mailBody = fileEngine.Process(dic, templateName);
                //Mail.send(MailSubject, custom_email, mailBody);
            }

            if (_error_code == 0)
            {
                JscriptMsg("Cập nhật thành công !", "", "Success");
            }
            else
            {
                JscriptMsg("Lỗi xảy ra: " + _error_code.ToString(), "", "Error");
            }
        }