Exemple #1
0
        //public async Task<bool> albertMail(Notification notification)
        //{
        //    try
        //    {
        //        string EmailFromAddress = System.Web.Configuration.WebConfigurationManager.AppSettings["EmailFromAddress"];
        //        string smtpUserName = System.Web.Configuration.WebConfigurationManager.AppSettings["SMTP-UserName"];
        //        string smtpPassword = System.Web.Configuration.WebConfigurationManager.AppSettings["SMTP-Password"];
        //        string myport = System.Web.Configuration.WebConfigurationManager.AppSettings["Port"];
        //        var from = new MailAddress(EmailFromAddress, "Admin_@_PartyEC");
        //        var to = new MailAddress("*****@*****.**");
        //        var useDefaultCredentials = true;
        //        var enableSsl = false;
        //      //  var replyto = "*****@*****.**"; // set here your email;
        //        var userName = smtpUserName;
        //        var password = smtpPassword;
        //        var port = int.Parse(myport);
        //        var host = System.Web.Configuration.WebConfigurationManager.AppSettings["SMTP-host"];
        //        userName = System.Web.Configuration.WebConfigurationManager.AppSettings["SMTP-UserName"];  // setup here the username;
        //        password = System.Web.Configuration.WebConfigurationManager.AppSettings["SMTP-Password"]; // setup here the password;
        //        bool.TryParse("true", out useDefaultCredentials); //setup here if it uses defaault credentials
        //        bool.TryParse("true", out enableSsl); //setup here if it uses ssl
        //       // int.TryParse(myport, out port); //setup here the port
        //        host = System.Web.Configuration.WebConfigurationManager.AppSettings["SMTP-host"]; //setup here the host

        //        using (var mail = new MailMessage(from, to))
        //        {
        //            mail.Subject = "testing mail by albert";
        //            mail.Body = "<table><tr>Thrithavam from table</tr></table>";
        //            mail.IsBodyHtml = true;

        //           // mail.ReplyToList.Add(new MailAddress(replyto, "*****@*****.**"));
        //            mail.ReplyToList.Add(from);
        //            mail.DeliveryNotificationOptions = DeliveryNotificationOptions.Delay |
        //                                               DeliveryNotificationOptions.OnFailure |
        //                                               DeliveryNotificationOptions.OnSuccess;
        //            using (var client = new SmtpClient())
        //            {
        //                client.Host = host;
        //                client.Port = int.Parse(myport);
        //                client.EnableSsl = enableSsl;
        //                client.UseDefaultCredentials = useDefaultCredentials;
        //                client.DeliveryMethod = SmtpDeliveryMethod.Network;
        //               // client.Credentials=
        //                if (!client.UseDefaultCredentials && !string.IsNullOrEmpty(userName) &&
        //                    !string.IsNullOrEmpty(password))
        //                {
        //                    client.Credentials = new NetworkCredential(userName, password);
        //                }
        //                client.Credentials = new NetworkCredential(userName, password);
        //                await client.SendMailAsync(mail);
        //            }
        //        }
        //    }
        //    catch(Exception ex)
        //    {

        //    }
        //    return true;

        //}


        //public async Task<bool> albertMail(Notification notification)
        //{
        //    try
        //    {
        //        string EmailFromAddress = System.Web.Configuration.WebConfigurationManager.AppSettings["EmailFromAddress"];
        //        string host = System.Web.Configuration.WebConfigurationManager.AppSettings["SMTP-host"];
        //        string smtpUserName = System.Web.Configuration.WebConfigurationManager.AppSettings["SMTP-UserName"];
        //        string smtpPassword = System.Web.Configuration.WebConfigurationManager.AppSettings["SMTP-Password"];
        //        string port = System.Web.Configuration.WebConfigurationManager.AppSettings["Port"];
        //        var from = new MailAddress(EmailFromAddress, "Admin_@_PartyEC");
        //        var to = new MailAddress("*****@*****.**");
        //        // var useDefaultCredentials = true;
        //        var enableSsl = false;
        //        //  var replyto = "*****@*****.**"; // set here your email;
        //        //  bool.TryParse("true", out useDefaultCredentials); //setup here if it uses defaault credentials
        //        bool.TryParse("true", out enableSsl); //setup here if it uses ssl
        //        // int.TryParse(myport, out port); //setup here the port
        //        // host = System.Web.Configuration.WebConfigurationManager.AppSettings["SMTP-host"]; //setup here the host
        //        using (var mail = new MailMessage(from, to))
        //        {
        //            mail.Subject = "ATTN";
        //            mail.Body = "wonderfull after ge";
        //            mail.IsBodyHtml = true;

        //            // mail.ReplyToList.Add(new MailAddress(replyto, "*****@*****.**"));
        //          //  mail.ReplyToList.Add(from);
        //            mail.DeliveryNotificationOptions = DeliveryNotificationOptions.Delay |
        //                                               DeliveryNotificationOptions.OnFailure |
        //                                               DeliveryNotificationOptions.OnSuccess;
        //            using (var client = new SmtpClient())
        //            {
        //                client.Host = host;
        //                client.Port = int.Parse(port);
        //                client.EnableSsl = enableSsl;
        //                //client.UseDefaultCredentials = useDefaultCredentials;
        //                client.DeliveryMethod = SmtpDeliveryMethod.Network;
        //                // client.Credentials=
        //                //if (!client.UseDefaultCredentials && !string.IsNullOrEmpty(smtpUserName) &&
        //                //    !string.IsNullOrEmpty(password))
        //                //{
        //                //    client.Credentials = new NetworkCredential(smtpUserName, smtpPassword);
        //                //}
        //                client.Credentials = new NetworkCredential(smtpUserName, smtpPassword);
        //                await client.SendMailAsync(mail);
        //            }
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        return false;
        //    }
        //    return true;

        // }

        public async Task <bool> NotificationEmailPush(Notification notification)
        {
            bool sendsuccess = false;

            try
            {
                //Get customer information
                OperationsStatus opstatus = new OperationsStatus();
                Customer         customer = null;
                customer = _customerBusiness.GetCustomer(notification.customer.ID, opstatus);

                Mail _mail = new Mail();
                using (StreamReader reader = new StreamReader(HttpContext.Current.Server.MapPath("~/PartyEcTemplates/Notifications.html")))
                {
                    _mail.Body = reader.ReadToEnd();
                }
                _mail.Body    = _mail.Body.Replace("{CustomerName}", customer.Name);
                _mail.Body    = _mail.Body.Replace("{Message}", notification.Message);
                _mail.Subject = notification.Title;
                _mail.To      = customer.Email;
                sendsuccess   = await _mailBusiness.MailSendAsync(_mail);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(sendsuccess);
        }
Exemple #2
0
        public JsonResult GetCustomerby(PagingInfo pageinfo)
        {
            var Messaging = new RenderMessaging();

            try
            {
                if (User == null || User.ChannelId <= 0)
                {
                    Messaging.isError   = true;
                    Messaging.messaging = "Vui lòng đăng nhập lại!";
                }

                Channel_Paging <CustomerModel> lstInfo = new Channel_Paging <CustomerModel>();

                int count, min = 0;

                var rs = _customerBus.GetCustomer(pageinfo, out count, out min);

                lstInfo.startItem = min;

                lstInfo.totalItems = count;

                lstInfo.listTable = rs;

                Messaging.Data = lstInfo;
            }
            catch
            {
                Messaging.isError   = true;
                Messaging.messaging = "Hiển thị danh sách khách hàng không thành công!";
            }
            return(Json(Messaging, JsonRequestBehavior.AllowGet));
        }
        public ActionResult CustomerForm(Guid id)
        {
            CustomerViewModel customerVM = null;

            try
            {
                if (id != Guid.Empty)
                {
                    customerVM          = Mapper.Map <Customer, CustomerViewModel>(_customerBusiness.GetCustomer(id));
                    customerVM.IsUpdate = true;
                }
                else
                {
                    customerVM          = new CustomerViewModel();
                    customerVM.IsUpdate = false;
                    customerVM.ID       = Guid.Empty;
                }
                customerVM.Titles = new TitlesViewModel()
                {
                    TitlesSelectList = _customerBusiness.GetTitleSelectList()
                };
                //customerVM.PaymentTerm = new PaymentTermViewModel()
                //{
                //    PaymentTermSelectList = _paymentTermBusiness.GetPaymentTermForSelectList()
                //};
                customerVM.CustomerCategory = new CustomerCategoryViewModel()
                {
                    CustomerCategorySelectList = _customerCategoryBusiness.GetCustomerCategoryForSelectList()
                };
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(PartialView("_CustomerForm", customerVM));
        }
Exemple #4
0
        public ActionResult AddEnquiryFollowup(Guid id, Guid enquiryID, Guid customerID)
        {
            EnquiryFollowupViewModel enquiryFollowupVM = new EnquiryFollowupViewModel();

            enquiryFollowupVM.IsUpdate = false;
            enquiryFollowupVM.Status   = "Open";
            if (id != Guid.Empty)
            {
                enquiryFollowupVM          = Mapper.Map <EnquiryFollowup, EnquiryFollowupViewModel>(_enquiryFollowupBusiness.GetEnquiryFollowup(id));
                enquiryFollowupVM.IsUpdate = true;
            }
            if (!enquiryFollowupVM.IsUpdate)
            {
                enquiryFollowupVM.Customer    = Mapper.Map <Customer, CustomerViewModel>(_customerBusiness.GetCustomer(customerID));
                enquiryFollowupVM.ContactName = enquiryFollowupVM.Customer.ContactPerson;
                enquiryFollowupVM.ContactNo   = enquiryFollowupVM.Customer.Mobile;
            }
            return(PartialView("_AddEnquiryFollowup", enquiryFollowupVM));
        }
Exemple #5
0
 public string GetCustomer(string ID)
 {
     try
     {
         OperationsStatusViewModel operationsStatus = new OperationsStatusViewModel();
         CustomerViewModel         customerObj      = Mapper.Map <Customer, CustomerViewModel>(_customerBusiness.GetCustomer(Int32.Parse(ID), Mapper.Map <OperationsStatusViewModel, OperationsStatus>(operationsStatus)));
         return(JsonConvert.SerializeObject(new { Result = "OK", Record = customerObj }));
     }
     catch (Exception ex)
     {
         return(JsonConvert.SerializeObject(new { Result = "ERROR", Message = ex.Message }));
     }
 }