Exemplo n.º 1
0
    private void SendEmail2()
    {
        //MailMessage msg = new MailMessage();
        //msg.From = new MailAddress("*****@*****.**", System.Configuration.ConfigurationManager.AppSettings["Title"]);
        //msg.To.Add(new MailAddress("*****@*****.**"));
        //msg.Subject = "asdasdasd";
        //msg.Body = "testing email";
        //msg.IsBodyHtml = true;
        ////SmtpClient smtp = new SmtpClient("mail.wit.co.id", 25);
        ////smtp.Credentials = new NetworkCredential("*****@*****.**", "Rikki12345");
        //SmtpClient smtp = new SmtpClient("mail.wit.co.id", 25);
        //smtp.Credentials = new NetworkCredential("*****@*****.**", "Rikki12345");
        ////smtp.UseDefaultCredentials = false;
        //smtp.EnableSsl = false;
        //smtp.Send(msg);

        //SEND EMAIL
        Class_Configuration _config = new Class_Configuration();
        var emailLogo = _config.Dynamic_Get_EmailLogo();

        using (StreamReader reader = new StreamReader(HttpContext.Current.Server.MapPath("~/assets/email-template/template-email-register.html")))
        {
            string body = "";
            body = reader.ReadToEnd();
            body = body.Replace("{name}", "Rikki Novar");
            body = body.Replace("{email}", "*****@*****.**");
            body = body.Replace("{password}", "asdasd");
            body = body.Replace("{title}", System.Configuration.ConfigurationManager.AppSettings["Title"]);
            body = body.Replace("{email_logo}", System.Configuration.ConfigurationManager.AppSettings["url"] + "/assets/images/email_logo/" + emailLogo);
            body = body.Replace("{shop_url}", System.Configuration.ConfigurationManager.AppSettings["url"]);
            Response.Write(OurClass.SendEmail("*****@*****.**", WebConfigurationManager.AppSettings["Title"] + " Account Registration", body, "").message);
        }
    }
Exemplo n.º 2
0
    public ReturnData AJAX_Forget_Password(string email)
    {
        try
        {
            DataClassesDataContext db = new DataClassesDataContext();
            if (IsExistsEmail(email))
            {
                var emp = db.TBEmployees.Where(x => !x.Deflag && x.Email == email).FirstOrDefault();
                if (emp != null)
                {
                    string text  = email + "-" + emp.Name.Substring(0, 2);
                    string token = this.EncryptPassword(text);
                    int    aa    = token.Length;
                    string pass  = EncryptToken(email, DateTime.Now.ToString("MMddHHmmss"));
                    aa = pass.Length;

                    emp.Password = pass;
                    db.SubmitChanges();
                    //SEND EMAIL
                    using (StreamReader reader = new StreamReader(HttpContext.Current.Server.MapPath("~/assets/email-template/template-email-forgot-password.html")))
                    {
                        Class_Configuration _config = new Class_Configuration();
                        var    emailLogo            = _config.Dynamic_Get_EmailLogo();
                        string body = "";
                        body = reader.ReadToEnd();
                        body = body.Replace("{name}", emp.Name);
                        body = body.Replace("{Url}", WebConfigurationManager.AppSettings["url"].ToString() + "/adminwitcommerce/reset-password.aspx?token=" + emp.Password);
                        body = body.Replace("{title}", System.Configuration.ConfigurationManager.AppSettings["Title"]);
                        body = body.Replace("{email_logo}", System.Configuration.ConfigurationManager.AppSettings["url"] + "/assets/images/email_logo/" + emailLogo);
                        body = body.Replace("{shop_url}", System.Configuration.ConfigurationManager.AppSettings["url"]);
                        OurClass.SendEmail(emp.Email, WebConfigurationManager.AppSettings["Title"] + " Reset Password", body, "");
                    }
                    return(ReturnData.MessageSuccess("Reset password link has been sent to your email, please check your inbox or spam folder.", null));
                }
                return(ReturnData.MessageSuccess("Employee Not Found", null));
            }
            else
            {
                return(ReturnData.MessageSuccess("Your email has not registered as Employee", null));
            }
        }
        catch (Exception ex)
        {
            Class_Log_Error log = new Class_Log_Error();
            log.Insert(ex.Message, ex.StackTrace);

            return(ReturnData.MessageFailed(ex.Message, null));
        }
    }
Exemplo n.º 3
0
    public ReturnData AJAX_Forget_Password(string email)
    {
        try
        {
            DataClassesDataContext db = new DataClassesDataContext();
            if (IsExistsEmail(email))
            {
                var cust = db.TBCustomers.Where(x => !x.Deflag && x.Email == email).FirstOrDefault();
                if (cust != null)
                {
                    string text  = email + "-" + cust.FirstName.Substring(0, 2);
                    string token = this.EncryptPassword(text);
                    int    aa    = token.Length;
                    string pass  = EncryptToken(email, DateTime.Now.ToString("MMddHHmmss"));
                    aa = pass.Length;

                    cust.Password = pass;
                    db.SubmitChanges();
                    //SEND EMAIL
                    using (StreamReader reader = new StreamReader(HttpContext.Current.Server.MapPath("~/assets/email-template/template-email-forgot-password.html")))
                    {
                        Class_Configuration _config = new Class_Configuration();
                        var    emailLogo            = _config.Dynamic_Get_EmailLogo();
                        string body = "";
                        body = reader.ReadToEnd();
                        body = body.Replace("{name}", cust.FirstName);
                        body = body.Replace("{Url}", WebConfigurationManager.AppSettings["url"].ToString() + "/reset-password.aspx?token=" + cust.Password);
                        body = body.Replace("{title}", System.Configuration.ConfigurationManager.AppSettings["Title"]);
                        body = body.Replace("{email_logo}", System.Configuration.ConfigurationManager.AppSettings["url"] + "/assets/images/email_logo/" + emailLogo);
                        body = body.Replace("{shop_url}", System.Configuration.ConfigurationManager.AppSettings["url"]);
                        OurClass.SendEmail(cust.Email, WebConfigurationManager.AppSettings["Title"] + " Reset Password", body, "");
                    }
                    return(ReturnData.MessageSuccess("OK", null));
                }
                return(ReturnData.MessageSuccess("", null));
            }
            else
            {
                return(ReturnData.MessageSuccess("", null));
            }
        }
        catch (Exception ex)
        {
            return(ReturnData.MessageFailed(ex.Message, null));
        }
    }
Exemplo n.º 4
0
    public ReturnData AJAX_Submit(int idOrder, string name, string email, string phoneNumber, string bank, decimal amount, string paymentDate, string notes, string baseImage, string fnImage)
    {
        try
        {
            DataClassesDataContext db = new DataClassesDataContext();

            DateTime myDate = DateTime.ParseExact(paymentDate, "yyyy-MM-dd HH:mm", System.Globalization.CultureInfo.InvariantCulture);

            TBOrder order = db.TBOrders.Where(x => !x.Deflag && x.IDOrder == idOrder).FirstOrDefault();
            if (order == null)
            {
                return(ReturnData.MessageFailed("Order not found", null));
            }
            TBPayment_Confirmation data = new TBPayment_Confirmation();
            data.IDOrder         = idOrder;
            data.ReferenceNumber = order.Reference;
            data.Name            = name;
            data.Email           = email;
            data.PhoneNumber     = phoneNumber;
            data.Bank            = bank;
            data.Amount          = amount;
            data.PaymentDate     = myDate;
            data.Notes           = notes;
            if (baseImage != "" && fnImage != "")
            {
                System.Drawing.Image _image = WITLibrary.ConvertCustom.Base64ToImage(baseImage);
                _image.Save(HttpContext.Current.Server.MapPath("/assets/images/payment_confirmation/" + DateTime.Now.ToString("ddmmyy") + "_" + fnImage));
                data.Image = DateTime.Now.ToString("ddmmyy") + "_" + fnImage;
            }
            db.TBPayment_Confirmations.InsertOnSubmit(data);
            //GANTI STATUS JADI AWAITING PAYMENT VERIFICATION
            order.IDOrderStatus = 13;

            db.SubmitChanges();

            //INSERT LOG ORDER
            Class_Log_Order logOrder = new Class_Log_Order();
            logOrder.Insert((int?)null, order.IDOrder, order.Reference, order.TBOrder_Status.Name, "Customer Payment Confirmation", order.TBCustomer.FirstName + ' ' + order.TBCustomer.LastName);

            //SEND EMAIL TO ADMIN
            using (StreamReader reader = new StreamReader(HttpContext.Current.Server.MapPath("~/assets/email-template/admin-payment-notification.html")))
            {
                string body = "";
                body = reader.ReadToEnd();
                body = body.Replace("{ReferenceCode}", data.ReferenceNumber);
                body = body.Replace("{CustomerName}", data.Name);
                body = body.Replace("{Name}", data.Name);
                body = body.Replace("{Email}", data.Email);
                body = body.Replace("{Date}", data.PaymentDate.ToString("dd/MM/yyyy hh:mm"));
                body = body.Replace("{Amount}", WITLibrary.ConvertString.ToCurrency(data.Amount.ToString()));
                body = body.Replace("{Bank}", data.Bank);
                body = body.Replace("{Notes}", data.Notes);
                string emailAdmin = db.TBConfigurations.Where(x => x.Name == "email_user").FirstOrDefault().Value;
                OurClass.SendEmail(emailAdmin, WebConfigurationManager.AppSettings["Title"] + " Confirm Payment for Order #" + data.ReferenceNumber, body, HttpContext.Current.Server.MapPath("/assets/images/payment_confirmation/" + DateTime.Now.ToString("ddmmyy") + "_" + fnImage));
            }

            //SEND EMAIL KE CUSTOMER
            Class_Configuration _config = new Class_Configuration();
            var emailLogo = _config.Dynamic_Get_EmailLogo();
            using (StreamReader reader = new StreamReader(HttpContext.Current.Server.MapPath("~/assets/email-template/template-email-paymentReceived.html")))
            {
                string body = "";
                body = reader.ReadToEnd();
                body = body.Replace("{name}", name);
                body = body.Replace("{nomorInvoice}", order.Reference);
                body = body.Replace("{amount}", WITLibrary.ConvertString.ToCurrency(order.TotalPaid.ToString()));
                body = body.Replace("{owner}", order.TBPayment_Method.Owner);
                body = body.Replace("{account}", order.TBPayment_Method.AccountNumber);
                body = body.Replace("{bank}", order.TBPayment_Method.Bank);
                body = body.Replace("{title}", System.Configuration.ConfigurationManager.AppSettings["Title"]);
                body = body.Replace("{email_logo}", System.Configuration.ConfigurationManager.AppSettings["url"] + "/assets/images/email_logo/" + emailLogo);
                body = body.Replace("{shop_url}", System.Configuration.ConfigurationManager.AppSettings["url"]);
                OurClass.SendEmail(email, WebConfigurationManager.AppSettings["Title"] + " Order Notification", body, "");
            }


            return(ReturnData.MessageSuccess("Order Confirmation submitted successfully", null));
        }
        catch (Exception ex)
        {
            Class_Log_Error log = new Class_Log_Error();
            log.Insert(ex.Message, ex.StackTrace);

            return(ReturnData.MessageFailed(ex.Message, null));
        }
    }
Exemplo n.º 5
0
    public ReturnData AJAX_Insert(string email)
    {
        try
        {
            Class_Customer         _customer = new Class_Customer();
            DataClassesDataContext db        = new DataClassesDataContext();
            Class_Configuration    _config   = new Class_Configuration();
            var customer   = _customer.Dynamic_GetData_ByEmail(email);
            var subscriber = Dynamic_GetData_ByEmail(email);
            if (customer != null)
            {
                if (customer.IsSubscribe == true)
                {
                    return(ReturnData.MessageFailed("Your email has been registered and signed up for newsletter", null));
                }
                else
                {
                    var UpdateCustomer = db.TBCustomers.Where(x => x.Email.ToLower() == email.ToLower() && !x.Deflag && x.Active).FirstOrDefault();
                    UpdateCustomer.IsSubscribe = true;
                    db.SubmitChanges();
                    return(ReturnData.MessageSuccess("Your email has been registered as member, You're succesfully signed up for newsletter", null));
                }
            }
            else if (subscriber != null)
            {
                return(ReturnData.MessageFailed("Your email has successfully subscribed", null));
            }
            else
            {
                TBNewsletter _newNewsletter = new TBNewsletter
                {
                    Email          = email,
                    Deflag         = false,
                    DateInsert     = DateTime.Now,
                    DateLastUpdate = DateTime.Now
                };
                db.TBNewsletters.InsertOnSubmit(_newNewsletter);
                db.SubmitChanges();

                var emailLogo = _config.Dynamic_Get_EmailLogo();

                using (StreamReader reader = new StreamReader(HttpContext.Current.Server.MapPath("~/assets/email-template/template-email-newsletter.html")))
                {
                    string body = "";
                    body = reader.ReadToEnd();
                    body = body.Replace("{name}", email);
                    body = body.Replace("{voucher}", "newcompaniion");
                    body = body.Replace("{title}", System.Configuration.ConfigurationManager.AppSettings["Title"]);
                    body = body.Replace("{email_logo}", System.Configuration.ConfigurationManager.AppSettings["url"] + "/assets/images/email_logo/" + emailLogo);
                    body = body.Replace("{shop_url}", System.Configuration.ConfigurationManager.AppSettings["url"]);
                    OurClass.SendEmail(email, System.Web.Configuration.WebConfigurationManager.AppSettings["Title"] + " - Subscriber", body, "");
                }

                return(ReturnData.MessageSuccess("Thank You For Subcribed on our website, your email address has been registered", null));
            }
        }
        catch (Exception ex)
        {
            Class_Log_Error log = new Class_Log_Error();
            log.Insert(ex.Message, ex.StackTrace);

            return(ReturnData.MessageFailed(ex.Message, null));
        }
    }
Exemplo n.º 6
0
    public ReturnData AJAX_FE_RegisterCustomGroup(string firstName, string lastName, string gender, string email, string password, string phoneNumber, DateTime birthday, bool isSubscribe, string addressname, string address, string postalCode, int idCountry, int idProvince, int idCity, int idDistrict, int idCustomerGroup, string DeliveryAddressName)
    {
        try
        {
            using (DataClassesDataContext db = new DataClassesDataContext())
            {
                if (idCustomerGroup == 3)
                {
                    if (IsExistsEmail(email))
                    {
                        return(ReturnData.MessageFailed("Email is already registered, Please update following customer data", null));
                    }

                    var        customerGroup = db.TBCustomer_Groups.Where(x => x.IDCustomer_Group == idCustomerGroup).FirstOrDefault();
                    TBCustomer _newCust      = new TBCustomer();
                    _newCust.FirstName        = firstName;
                    _newCust.LastName         = lastName;
                    _newCust.Gender           = gender;
                    _newCust.Email            = email;
                    _newCust.Password         = EncryptPassword(password);
                    _newCust.PhoneNumber      = phoneNumber;
                    _newCust.Birthday         = birthday;
                    _newCust.IsSubscribe      = isSubscribe;
                    _newCust.Active           = true;
                    _newCust.DateInsert       = DateTime.Now;
                    _newCust.DateLastUpdate   = DateTime.Now;
                    _newCust.IDCustomer_Group = idCustomerGroup;
                    db.TBCustomers.InsertOnSubmit(_newCust);
                    //db.SubmitChanges();

                    TBAddress _newAddress = new TBAddress();
                    _newAddress.TBCustomer     = _newCust;
                    _newAddress.IDCountry      = idCountry;
                    _newAddress.IDProvince     = idProvince;
                    _newAddress.IDCity         = idCity;
                    _newAddress.IDDistrict     = idDistrict;
                    _newAddress.Name           = addressname;
                    _newAddress.Address        = address;
                    _newAddress.Phone          = _newCust.PhoneNumber;
                    _newAddress.PostalCode     = postalCode;
                    _newAddress.PeopleName     = DeliveryAddressName;
                    _newAddress.Active         = true;
                    _newAddress.DateInsert     = DateTime.Now;
                    _newAddress.DateLastUpdate = DateTime.Now;
                    db.TBAddresses.InsertOnSubmit(_newAddress);
                    db.SubmitChanges();

                    Dictionary <string, dynamic> result = new Dictionary <string, dynamic>();
                    result.Add("IDCustomer", _newCust.IDCustomer);
                    result.Add("IDAddress", _newAddress.IDAddress);

                    //SEND EMAIL
                    using (StreamReader reader = new StreamReader(HttpContext.Current.Server.MapPath("~/assets/email-template/template-email-register.html")))
                    {
                        Class_Configuration _config = new Class_Configuration();
                        var    emailLogo            = _config.Dynamic_Get_EmailLogo();
                        string body = "";
                        body = reader.ReadToEnd();
                        body = body.Replace("{name}", _newCust.FirstName);
                        body = body.Replace("{email}", _newCust.Email);
                        body = body.Replace("{password}", password);
                        body = body.Replace("{title}", System.Configuration.ConfigurationManager.AppSettings["Title"]);
                        body = body.Replace("{email_logo}", System.Configuration.ConfigurationManager.AppSettings["url"] + "/assets/images/email_logo/" + emailLogo);
                        body = body.Replace("{shop_url}", System.Configuration.ConfigurationManager.AppSettings["url"]);
                        OurClass.SendEmail(_newCust.Email, WebConfigurationManager.AppSettings["Title"] + " Account Registration", body, "");
                    }

                    return(ReturnData.MessageSuccess("Register success", result));
                }
                else
                {
                    var adminOrder = db.TBCustomers.Where(x => x.IDCustomer_Group == 4 && x.Email.ToLower() == email).FirstOrDefault();
                    if (adminOrder == null)
                    {
                        return(ReturnData.MessageFailed("Account not found", null));
                    }

                    TBAddress _newAddress = new TBAddress();
                    _newAddress.IDCustomer     = adminOrder.IDCustomer;
                    _newAddress.IDCountry      = idCountry;
                    _newAddress.IDProvince     = idProvince;
                    _newAddress.IDCity         = idCity;
                    _newAddress.IDDistrict     = idDistrict;
                    _newAddress.Name           = addressname;
                    _newAddress.Address        = address;
                    _newAddress.Phone          = phoneNumber;
                    _newAddress.PostalCode     = postalCode;
                    _newAddress.PeopleName     = DeliveryAddressName;
                    _newAddress.Active         = true;
                    _newAddress.DateInsert     = DateTime.Now;
                    _newAddress.DateLastUpdate = DateTime.Now;
                    db.TBAddresses.InsertOnSubmit(_newAddress);
                    db.SubmitChanges();

                    Dictionary <string, dynamic> result = new Dictionary <string, dynamic>();
                    result.Add("IDCustomer", adminOrder.IDCustomer);
                    result.Add("IDAddress", _newAddress.IDAddress);

                    return(ReturnData.MessageSuccess("Register success", result));
                }
            }
        }
        catch (Exception ex)
        {
            return(ReturnData.MessageFailed(ex.Message, null));
        }
    }
Exemplo n.º 7
0
    public ReturnData AJAX_AutoCancel()
    {
        try
        {
            DataClassesDataContext db   = new DataClassesDataContext();
            double autocancel           = double.Parse(Dynamic_GetValue_AutoCancel());
            var    dataOrder            = db.TBOrders.Where(x => !x.Deflag && x.TBOrder_Status.Paid == false && x.TBOrder_Status.Logable == false && x.TBOrder_Status.Delivery == false && x.TBOrder_Status.Shipped == false && x.TBOrder_Status.Restock == false && DateTime.Now >= x.DateInsert.AddHours(autocancel));
            Class_Configuration _config = new Class_Configuration();
            var emailLogo = _config.Dynamic_Get_EmailLogo();
            if (dataOrder == null || dataOrder.Count() == 0)
            {
                return(ReturnData.MessageFailed("Data not found", null));
            }
            else
            {
                foreach (var item in dataOrder)
                {
                    if (item.IDVoucher != null)
                    {
                        item.TBVoucher.Used -= 1;
                    }

                    var ordDetail = db.TBOrder_Details.Where(x => x.IDOrder == item.IDOrder);
                    foreach (var detail in ordDetail)
                    {
                        detail.TBProduct_Combination.Quantity += detail.Quantity;
                    }
                    item.IDOrderStatus  = db.TBOrder_Status.Where(x => !x.Deflag && x.Paid == false && x.Logable == true && x.Delivery == false && x.Shipped == false && x.Restock == true).FirstOrDefault().IDOrderStatus;
                    item.DateLastUpdate = DateTime.Now;

                    //INSERT LOG ORDER
                    Class_Log_Order logOrder = new Class_Log_Order();
                    logOrder.Insert((int?)null, item.IDOrder, item.Reference, item.TBOrder_Status.Name, "Autocancel By System ", item.TBCustomer.FirstName + ' ' + item.TBCustomer.LastName);

                    using (StreamReader reader = new StreamReader(HttpContext.Current.Server.MapPath("~/assets/email-template/template-email-canceled.html")))
                    {
                        string body = "";
                        body = reader.ReadToEnd();
                        body = body.Replace("{name}", item.TBCustomer.FirstName);
                        body = body.Replace("{amount}", item.TotalPaid.ToString());
                        body = body.Replace("{owner}", item.TBPayment_Method.Owner);
                        body = body.Replace("{account}", item.TBPayment_Method.AccountNumber);
                        body = body.Replace("{bank}", item.TBPayment_Method.Bank);
                        if (item.InvoiceNumber == null)
                        {
                            body = body.Replace("{nomorInvoice}", item.Reference);
                        }
                        else
                        {
                            body = body.Replace("{nomorInvoice}", item.InvoiceNumber);
                        }
                        body = body.Replace("{title}", System.Configuration.ConfigurationManager.AppSettings["Title"]);
                        body = body.Replace("{email_logo}", System.Configuration.ConfigurationManager.AppSettings["url"] + "/assets/images/email_logo/" + emailLogo);
                        body = body.Replace("{shop_url}", System.Configuration.ConfigurationManager.AppSettings["url"]);
                        OurClass.SendEmail(item.TBCustomer.Email, System.Web.Configuration.WebConfigurationManager.AppSettings["Title"] + " - Order Cancelled", body, "");
                    }
                }
                db.SubmitChanges();
                return(ReturnData.MessageSuccess("Some Order cancelled automatically", null));
            }
        }
        catch (Exception ex)
        {
            Class_Log_Error log = new Class_Log_Error();
            log.Insert(ex.Message, ex.StackTrace);

            return(ReturnData.MessageFailed(ex.Message, null));
        }
    }