diff --git a/400-SOURCECODE/AIAHTML5.API/Constants/AIAConstants.cs b/400-SOURCECODE/AIAHTML5.API/Constants/AIAConstants.cs
index 52bcf5c..acb5195 100644
--- a/400-SOURCECODE/AIAHTML5.API/Constants/AIAConstants.cs
+++ b/400-SOURCECODE/AIAHTML5.API/Constants/AIAConstants.cs
@@ -8,8 +8,10 @@ namespace AIAHTML5.API.Constants
public class AIAConstants
{
public const string ERROR_IN_FECTHING_DETAILS = "Error in fecthing details.";
-
public const string USER_NOT_FOUND = "User not found.";
+ public const string MAIL_NOT_SENT = "Mail not sent.";
+
+
}
}
\ No newline at end of file
diff --git a/400-SOURCECODE/AIAHTML5.API/Controllers/ForgotUserController.cs b/400-SOURCECODE/AIAHTML5.API/Controllers/ForgotUserController.cs
index 3a600f7..e0ef377 100644
--- a/400-SOURCECODE/AIAHTML5.API/Controllers/ForgotUserController.cs
+++ b/400-SOURCECODE/AIAHTML5.API/Controllers/ForgotUserController.cs
@@ -33,27 +33,40 @@ namespace AIAHTML5.API.Controllers
//}
public HttpResponseMessage Post([FromBody]JObject userInfo)
{
- ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
- logger.Debug("inside POST");
+ ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
+ logger.Debug("inside POST in ForgotUserController for emailId = " + userInfo["emailId"]);
dynamic userData = AIAHTML5.API.Models.Users.GetUserByEmail(userInfo);
if (Convert.ToString(userData) != AIAConstants.USER_NOT_FOUND && Convert.ToString(userData) != AIAConstants.ERROR_IN_FECTHING_DETAILS)
- {
+ {
+ logger.Debug("inside if in ForgotUserController userData.loginId= " + userData.loginId);
bool isMailSent = false;
- string userDetails = Newtonsoft.Json.JsonConvert.SerializeObject(userData);
- if (Convert.ToBoolean(userInfo["isPassword"]))
- isMailSent = AIAHTML5.API.Models.ResetUser.SendEmail(userData, true);
- else
- isMailSent = AIAHTML5.API.Models.ResetUser.SendEmail(userData, false);
-
+ string userDetails = Newtonsoft.Json.JsonConvert.SerializeObject(userData);
+
+ logger.Debug("1. inside if in ForgotUserController userDetails= " + userDetails);
+
+ if (Convert.ToBoolean(userInfo["isPassword"]))
+ {
+ logger.Debug("2. isPassword= " + Convert.ToBoolean(userInfo["isPassword"]));
+
+ isMailSent = AIAHTML5.API.Models.ResetUser.SendEmail(userData, true);
+ }
+ else
+ {
+ logger.Debug("3. isPassword= " + Convert.ToBoolean(userInfo["isPassword"]));
+
+ isMailSent = AIAHTML5.API.Models.ResetUser.SendEmail(userData, false);
+ }
+ logger.Debug("isMailSent= " + isMailSent);
if (isMailSent)
return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(userDetails) };
else
- return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent(userData) };
+ return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(AIAConstants.MAIL_NOT_SENT)};
}
else
- {
- return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(userData) }; //new StringContent(userData)
+ {
+ logger.Debug("inside else in ForgotUserController userData= " + userData);
+ return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(userData)}; //new StringContent(userData)
}
}
diff --git a/400-SOURCECODE/AIAHTML5.API/Models/ResetUser.cs b/400-SOURCECODE/AIAHTML5.API/Models/ResetUser.cs
index 4e24e14..e90deb6 100644
--- a/400-SOURCECODE/AIAHTML5.API/Models/ResetUser.cs
+++ b/400-SOURCECODE/AIAHTML5.API/Models/ResetUser.cs
@@ -12,14 +12,17 @@ using AIAHTML5.API.Utility;
using System.Text;
using System.IO;
using System.Net.Mime;
-using System.Configuration;
+using System.Configuration;
namespace AIAHTML5.API.Models
{
public class ResetUser
{
public static bool SendEmail(dynamic UserDetails, bool isPassword)
- {
+ {
+ ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
+ logger.Debug("inside SendEmail in for isPassword =" + isPassword);
+
try
{
List lstLinkedResource = new List();
@@ -63,15 +66,16 @@ namespace AIAHTML5.API.Models
resetPasswordLink = site_url + "?em:" + HttpUtility.UrlEncode(userMail);
}
else
- templatePath = "~/Templates/forgot-UserId.html";
-
+ templatePath = "~/Templates/forgot-UserId.html";
+
+ logger.Debug("inside SendEmail for templatePath= " + templatePath + ", userId= " + userId + ", userMail= " + userMail + ",fullName= " + fullName + ",resetPasswordLink= " + resetPasswordLink);
string mailBody = ResetUser.GetMailBodyTextFromTemplate(templatePath, userId, userMail, fullName, resetPasswordLink);
lstToAddress.Add(userMail);
- emailText = mailBody;
-
-
+ emailText = mailBody;
+
+ logger.Debug("emailText= " + emailText);
// for embedding images in email
if (emailText.Contains("
filterCondition = Builders.Filter.Eq("emailId", userInfo["emailId"].ToString().ToLower());
dynamic userDetails = collection.Find(Builders.Filter.And(filterCondition)).SingleOrDefault();
-
if (userDetails != null)
+ {
+ logger.Debug("userDetails= " + userDetails.loginId);
+
return userDetails;
+ }
else
+ {
+ logger.Debug("user not found");
return AIAConstants.USER_NOT_FOUND;
+ }
}
catch (Exception e)
{
- logger.Fatal("Exception= " + e.Message);
+ logger.Fatal("Exception= " + e.Message+", stacktrace = "+e.StackTrace);
return AIAConstants.ERROR_IN_FECTHING_DETAILS;
}
}
diff --git a/400-SOURCECODE/AIAHTML5.API/Utility/EmailUtility.cs b/400-SOURCECODE/AIAHTML5.API/Utility/EmailUtility.cs
index 125f479..7b55008 100644
--- a/400-SOURCECODE/AIAHTML5.API/Utility/EmailUtility.cs
+++ b/400-SOURCECODE/AIAHTML5.API/Utility/EmailUtility.cs
@@ -7,7 +7,8 @@ using System.Collections;
using System.Xml;
using System.Text;
using System.IO;
-using System.Net.Mail;
+using System.Net.Mail;
+using log4net;
namespace AIAHTML5.API.Utility
{
@@ -41,7 +42,10 @@ namespace AIAHTML5.API.Utility
}
public void SendSmtpEmail()
- {
+ {
+ ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
+ logger.Debug("inside SendSmtpEmail");
+
try
{
MailMessage sMail = new MailMessage();
@@ -53,8 +57,8 @@ namespace AIAHTML5.API.Utility
{
foreach (var sItem in sToAddresses)
{
- sMail.To.Add(sItem);
-
+ sMail.To.Add(sItem);
+ logger.Debug("sToAddresses= " + sItem);
}
}
@@ -62,7 +66,9 @@ namespace AIAHTML5.API.Utility
{
foreach (var sItem in sBccAddresses)
{
- sMail.Bcc.Add(sItem);
+ sMail.Bcc.Add(sItem);
+ logger.Debug("sBccAddresses= " + sItem);
+
}
}
@@ -70,21 +76,31 @@ namespace AIAHTML5.API.Utility
if (sAlternateView != null)
{
- sMail.AlternateViews.Add(sAlternateView);
+ sMail.AlternateViews.Add(sAlternateView);
+ logger.Debug("sAlternateView= " + sAlternateView);
+
}
else
{
- sMail.Body = sBodyText;
+ sMail.Body = sBodyText;
+ logger.Debug("sMail.Body= " + sBodyText);
+
}
- sMail.Subject = sSubject;
+ sMail.Subject = sSubject;
+ logger.Debug("sMail.Subject= " + sSubject);
+
if (sAttachments != null)
{
foreach (var sItem in sAttachments)
{
- sMail.Attachments.Add(sItem);
+ sMail.Attachments.Add(sItem);
+ logger.Debug("sAttachments= " + sAttachments);
+
+
}
- }
+ }
+ logger.Debug("sUserName= " + sUserName + ", sPassword= " + sPassword);
SmtpServer.Port = iPort;
SmtpServer.Credentials = new System.Net.NetworkCredential(sUserName, sPassword);
@@ -105,12 +121,14 @@ namespace AIAHTML5.API.Utility
}
mm.IsBodyHtml = true;
- SendMail(mm);
+ SendMail(mm);
+ logger.Debug("after sending email");
}
}
catch (Exception ex)
- {
+ {
+ logger.Fatal("exception in SendSmtpEmail.msg= " + ex.Message + ", stacktarce= " + ex.StackTrace);
throw ex;
}
}
diff --git a/400-SOURCECODE/AIAHTML5.API/Web.config b/400-SOURCECODE/AIAHTML5.API/Web.config
index 8d132b0..a5505d4 100644
--- a/400-SOURCECODE/AIAHTML5.API/Web.config
+++ b/400-SOURCECODE/AIAHTML5.API/Web.config
@@ -37,8 +37,8 @@
-
+
diff --git a/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll b/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll
index c65b7d8..189a00b 100644
--- a/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll
+++ b/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll
diff --git a/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll.config b/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll.config
index 3c4b171..c0fefa7 100644
--- a/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll.config
+++ b/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll.config
@@ -39,6 +39,7 @@
+
@@ -48,7 +49,7 @@
- 192.168.90.157:27017
+ localhost:27017
AIA
diff --git a/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.pdb b/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.pdb
index a8486a7..a0ec4f9 100644
--- a/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.pdb
+++ b/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.pdb
diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js
index de9f8b6..2c176e1 100644
--- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js
+++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js
@@ -179,7 +179,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
$rootScope.SendMailToUser = function (userInfo, isMailForPassword) {
if ((userInfo.emailId != null) && (userInfo.emailId != '')) {
if (validateEmail(userInfo.emailId)) {
- if (isMailForPassword == 'true')
+ if (isMailForPassword == true)
userInfo.isPassword = true;
else
userInfo.isPassword = false;
@@ -187,10 +187,13 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
AuthenticationService.SendMailToUser(userInfo)
.then(function (result) {
if (result == LoginConstants.USER_NOT_FOUND) {
- alert("Error occured.");
+ alert(LoginConstants.USER_NOT_FOUND);
}
else if (result == LoginConstants.ERROR_IN_FECTHING_DETAILS) {
- alert("Error occured.");
+ alert("An error occured.");
+ }
+ else if (result == LoginConstants.MAIL_NOT_SENT) {
+ alert("Due to some issue, email not sent.");
}
else {
if (result.loginId != undefined || result.loginId != "" || result.loginId != null) {
diff --git a/400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js b/400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js
index eb87a6f..bac9f02 100644
--- a/400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js
+++ b/400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js
@@ -283,6 +283,7 @@ AIA.constant('ImageTypes', ['Illustration', 'Cadaver Photograph', 'Radiograph'])
AIA.constant("LoginConstants", {
"USER_NOT_FOUND": "User not found.",
"ERROR_IN_FECTHING_DETAILS": "Error in fecthing details.",
+ "MAIL_NOT_SENT" : "Mail not sent.",
})
diff --git a/400-SOURCECODE/AIAHTML5.Web/index.html b/400-SOURCECODE/AIAHTML5.Web/index.html
index 4866cbd..3d7bbb1 100644
--- a/400-SOURCECODE/AIAHTML5.Web/index.html
+++ b/400-SOURCECODE/AIAHTML5.Web/index.html
@@ -243,7 +243,7 @@
@@ -268,7 +268,7 @@