예제 #1
0
        /// <summary>
        /// 新增用户
        /// </summary>
        /// <param name="customer">用户的注册信息</param>
        /// <returns>用户信息</returns>
        public static CustomerInfo CreateCustomer(CustomerInfo customer)
        {
            try
            {
                CustomerInfo item = CustomerDA.CreateCustomer(customer);
                if (item.SysNo > 0)
                {
                    if (!string.IsNullOrEmpty(customer.Email))
                    {
                        AsyncEmail email       = new AsyncEmail();
                        string     mailSubject = string.Empty;

                        email.MailAddress = customer.Email;
                        email.CustomerID  = item.CustomerID;
                        email.ImgBaseUrl  = ConstValue.CDNWebDomain;
                        email.Status      = (int)EmailStatus.NotSend;
                        email.MailBody    = MailHelper.GetMailTemplateBody("RegisterSuccess", out mailSubject);
                        email.MailSubject = mailSubject.Replace("[CustomerID]", item.CustomerID);
                        email.MailBody    = email.MailBody.Replace("[CustomerID]", item.CustomerID).Replace("[ImgBaseUrl]", email.ImgBaseUrl)
                                            .Replace("[WebBaseUrl]", ConstValue.WebDomain).Replace("[CurrentDateTime]", DateTime.Now.ToString("yyyy-MM-dd")).Replace("[Year]", DateTime.Now.Year.ToString());

                        EmailDA.SendEmail(email);
                    }
                }

                return(item);
            }
            catch (Exception ex)
            {
                ECommerce.Utility.Logger.WriteLog(string.Format("用户注册异常,异常信息:{0}!", ex.ToString()), "RegisteCustomer", "RegisteCustomerFailure");
                return(customer);
            }
        }