|
@ -23,66 +23,95 @@ namespace EasyBL.WEBAPP.SYS |
|
|
{ |
|
|
{ |
|
|
public class SignupService : ServiceBase |
|
|
public class SignupService : ServiceBase |
|
|
{ |
|
|
{ |
|
|
public static string SERVER_IP = "localhost"; |
|
|
|
|
|
public static string SERVER_PORT = "3466"; |
|
|
|
|
|
|
|
|
//public static string SERVER_IP = "localhost";
|
|
|
|
|
|
//public static string SERVER_PORT = "3466";
|
|
|
|
|
|
|
|
|
|
|
|
public static string SERVER_IP = "www.origtek.com"; |
|
|
|
|
|
public static string SERVER_PORT = "9105"; |
|
|
|
|
|
|
|
|
//使用者以信箱註冊
|
|
|
//使用者以信箱註冊
|
|
|
public HttpResponseMessage SignupWithEmail(SETB_CMS_Member newUser) |
|
|
public HttpResponseMessage SignupWithEmail(SETB_CMS_Member newUser) |
|
|
{ |
|
|
{ |
|
|
//string sMsg = null;
|
|
|
//string sMsg = null;
|
|
|
SuccessResponseMessage srm = SugarBase.ExecTran(db => |
|
|
|
|
|
{ |
|
|
|
|
|
do |
|
|
|
|
|
{ |
|
|
|
|
|
string sAccount = newUser.Email; |
|
|
|
|
|
string sPassword = newUser.Password; |
|
|
|
|
|
string sEmail = newUser.Email; |
|
|
|
|
|
string sFirstName = newUser.FirstName; |
|
|
|
|
|
string sLastName = newUser.LastName; |
|
|
|
|
|
//string sSubscribe = newUser.Subscribe;
|
|
|
|
|
|
string sMemberID = Guid.NewGuid().ToString(); //會員編號為GUID
|
|
|
|
|
|
string sOrgID = "TG"; //公司編號預設為TG
|
|
|
|
|
|
string sStatus = "0"; //會員狀態為未驗證(F)
|
|
|
|
|
|
string sType = "Email"; |
|
|
|
|
|
|
|
|
|
|
|
string sError = ""; //寄信若有錯誤回傳之訊息
|
|
|
|
|
|
|
|
|
SuccessResponseMessage srm = null; |
|
|
|
|
|
var db = SugarBase.GetIntance(); |
|
|
|
|
|
string sError = null; |
|
|
|
|
|
|
|
|
string sEncryptPwd = SecurityUtil.Encrypt(sPassword); //密碼加密
|
|
|
|
|
|
newUser.MemberID = sMemberID; |
|
|
|
|
|
newUser.OrgID = sOrgID; |
|
|
|
|
|
newUser.Status = sStatus; |
|
|
|
|
|
newUser.Password = sEncryptPwd; |
|
|
|
|
|
newUser.Account = newUser.Email; |
|
|
|
|
|
newUser.MemberType = sType; |
|
|
|
|
|
|
|
|
|
|
|
//開始寄信
|
|
|
|
|
|
var oEmail = new Emails(); //寄件人
|
|
|
|
|
|
var toEmail = new List<EmailTo>(); //收件人
|
|
|
|
|
|
var oEmailTo = new EmailTo //收件人資訊
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
do |
|
|
|
|
|
{ |
|
|
|
|
|
string sAccount = newUser.Email; |
|
|
|
|
|
string sPassword = newUser.Password; |
|
|
|
|
|
string sEmail = newUser.Email; |
|
|
|
|
|
string sFirstName = newUser.FirstName; |
|
|
|
|
|
string sLastName = newUser.LastName; |
|
|
|
|
|
//string sSubscribe = newUser.Subscribe;
|
|
|
|
|
|
string sMemberID = Guid.NewGuid().ToString(); //會員編號為GUID
|
|
|
|
|
|
string sOrgID = "TG"; //公司編號預設為TG
|
|
|
|
|
|
string sStatus = "0"; //會員狀態為未驗證(F)
|
|
|
|
|
|
string sType = "Email"; |
|
|
|
|
|
|
|
|
|
|
|
var checkAccount = db.Queryable<SETB_CMS_Member>() |
|
|
|
|
|
.Where(x => x.OrgID == sOrgID && x.Account == sAccount) |
|
|
|
|
|
.Count(); |
|
|
|
|
|
|
|
|
|
|
|
if (checkAccount > 0) |
|
|
{ |
|
|
{ |
|
|
ToUserID = newUser.MemberID, |
|
|
|
|
|
ToUserName = newUser.LastName, |
|
|
|
|
|
ToEmail = newUser.Email, |
|
|
|
|
|
Type = "to" |
|
|
|
|
|
}; |
|
|
|
|
|
toEmail.Add(oEmailTo); |
|
|
|
|
|
oEmail.FromUserName = "【ShowEasy 會員認證】"; //取fonfig
|
|
|
|
|
|
oEmail.Title = "感謝您註冊ShowEasy"; //取fonfig
|
|
|
|
|
|
oEmail.EmailBody = VerifyAccount_Mail(newUser.OrgID, newUser.MemberID, newUser.FirstName); |
|
|
|
|
|
oEmail.IsCCSelf = false; |
|
|
|
|
|
oEmail.Attachments = null; |
|
|
|
|
|
oEmail.EmailTo = toEmail; |
|
|
|
|
|
var bSend = new MailService(sOrgID, true).MailFactory(oEmail, out sError); |
|
|
|
|
|
|
|
|
|
|
|
var iRel = db.Insertable(newUser).ExecuteCommand(); |
|
|
|
|
|
|
|
|
sError = @"該帳號已註冊"; //該帳號無效
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
srm = new SuccessResponseMessage(null, null); |
|
|
|
|
|
srm.DATA.Add(BLWording.REL, newUser); |
|
|
|
|
|
} while (false); |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return srm; |
|
|
|
|
|
|
|
|
string sEncryptPwd = SecurityUtil.Encrypt(sPassword); //密碼加密
|
|
|
|
|
|
newUser.MemberID = sMemberID; |
|
|
|
|
|
newUser.OrgID = sOrgID; |
|
|
|
|
|
newUser.Status = sStatus; |
|
|
|
|
|
newUser.Password = sEncryptPwd; |
|
|
|
|
|
newUser.Account = newUser.Email; |
|
|
|
|
|
newUser.MemberType = sType; |
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
var iRel = db.Insertable(newUser).ExecuteCommand(); |
|
|
|
|
|
|
|
|
|
|
|
//開始寄信
|
|
|
|
|
|
var oEmail = new Emails(); //寄件人
|
|
|
|
|
|
var toEmail = new List<EmailTo>(); //收件人
|
|
|
|
|
|
var oEmailTo = new EmailTo //收件人資訊
|
|
|
|
|
|
{ |
|
|
|
|
|
ToUserID = newUser.MemberID, |
|
|
|
|
|
ToUserName = newUser.LastName, |
|
|
|
|
|
ToEmail = newUser.Email, |
|
|
|
|
|
Type = "to" |
|
|
|
|
|
}; |
|
|
|
|
|
toEmail.Add(oEmailTo); |
|
|
|
|
|
oEmail.FromUserName = "【ShowEasy 會員認證】"; //取fonfig
|
|
|
|
|
|
oEmail.Title = "感謝您註冊ShowEasy"; //取fonfig
|
|
|
|
|
|
oEmail.EmailBody = VerifyAccount_Mail(newUser.OrgID, newUser.MemberID, newUser.FirstName); |
|
|
|
|
|
oEmail.IsCCSelf = false; |
|
|
|
|
|
oEmail.Attachments = null; |
|
|
|
|
|
oEmail.EmailTo = toEmail; |
|
|
|
|
|
var bSend = new MailService(sOrgID, true).MailFactory(oEmail, out sError); |
|
|
|
|
|
|
|
|
|
|
|
srm = new SuccessResponseMessage(null, null); |
|
|
|
|
|
srm.DATA.Add(BLWording.REL, newUser); |
|
|
|
|
|
} while (false); |
|
|
|
|
|
} |
|
|
|
|
|
catch (Exception ex) |
|
|
|
|
|
{ |
|
|
|
|
|
sError = Util.GetLastExceptionMsg(ex); |
|
|
|
|
|
} |
|
|
|
|
|
finally |
|
|
|
|
|
{ |
|
|
|
|
|
if (null != sError) |
|
|
|
|
|
{ |
|
|
|
|
|
srm = new SuccessResponseMessage(null, null) |
|
|
|
|
|
{ |
|
|
|
|
|
STATUSCODE = (int)StatusCodeEnum.ParameterError, |
|
|
|
|
|
MSG = sError |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return HttpResponseExtension.ToJson(JsonConvert.SerializeObject(srm)); |
|
|
return HttpResponseExtension.ToJson(JsonConvert.SerializeObject(srm)); |
|
|
} |
|
|
} |
|
|