Commit 1045b02d02d9ecdbb93ca9075af3e7a58db42e56
1 parent
a949d27f
introduced logs and some conditions.
Showing
12 changed files
with
99 additions
and
46 deletions
400-SOURCECODE/AIAHTML5.API/Constants/AIAConstants.cs
... | ... | @@ -8,8 +8,10 @@ namespace AIAHTML5.API.Constants |
8 | 8 | public class AIAConstants |
9 | 9 | { |
10 | 10 | public const string ERROR_IN_FECTHING_DETAILS = "Error in fecthing details."; |
11 | - | |
12 | 11 | public const string USER_NOT_FOUND = "User not found."; |
12 | + public const string MAIL_NOT_SENT = "Mail not sent."; | |
13 | + | |
14 | + | |
13 | 15 | |
14 | 16 | } |
15 | 17 | } |
16 | 18 | \ No newline at end of file | ... | ... |
400-SOURCECODE/AIAHTML5.API/Controllers/ForgotUserController.cs
... | ... | @@ -33,27 +33,40 @@ namespace AIAHTML5.API.Controllers |
33 | 33 | //} |
34 | 34 | public HttpResponseMessage Post([FromBody]JObject userInfo) |
35 | 35 | { |
36 | - ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); | |
37 | - logger.Debug("inside POST"); | |
36 | + ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); | |
37 | + logger.Debug("inside POST in ForgotUserController for emailId = " + userInfo["emailId"]); | |
38 | 38 | |
39 | 39 | dynamic userData = AIAHTML5.API.Models.Users.GetUserByEmail(userInfo); |
40 | 40 | if (Convert.ToString(userData) != AIAConstants.USER_NOT_FOUND && Convert.ToString(userData) != AIAConstants.ERROR_IN_FECTHING_DETAILS) |
41 | - { | |
41 | + { | |
42 | + logger.Debug("inside if in ForgotUserController userData.loginId= " + userData.loginId); | |
42 | 43 | bool isMailSent = false; |
43 | - string userDetails = Newtonsoft.Json.JsonConvert.SerializeObject(userData); | |
44 | - if (Convert.ToBoolean(userInfo["isPassword"])) | |
45 | - isMailSent = AIAHTML5.API.Models.ResetUser.SendEmail(userData, true); | |
46 | - else | |
47 | - isMailSent = AIAHTML5.API.Models.ResetUser.SendEmail(userData, false); | |
48 | - | |
44 | + string userDetails = Newtonsoft.Json.JsonConvert.SerializeObject(userData); | |
45 | + | |
46 | + logger.Debug("1. inside if in ForgotUserController userDetails= " + userDetails); | |
47 | + | |
48 | + if (Convert.ToBoolean(userInfo["isPassword"])) | |
49 | + { | |
50 | + logger.Debug("2. isPassword= " + Convert.ToBoolean(userInfo["isPassword"])); | |
51 | + | |
52 | + isMailSent = AIAHTML5.API.Models.ResetUser.SendEmail(userData, true); | |
53 | + } | |
54 | + else | |
55 | + { | |
56 | + logger.Debug("3. isPassword= " + Convert.ToBoolean(userInfo["isPassword"])); | |
57 | + | |
58 | + isMailSent = AIAHTML5.API.Models.ResetUser.SendEmail(userData, false); | |
59 | + } | |
60 | + logger.Debug("isMailSent= " + isMailSent); | |
49 | 61 | if (isMailSent) |
50 | 62 | return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(userDetails) }; |
51 | 63 | else |
52 | - return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent(userData) }; | |
64 | + return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(AIAConstants.MAIL_NOT_SENT)}; | |
53 | 65 | } |
54 | 66 | else |
55 | - { | |
56 | - return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(userData) }; //new StringContent(userData) | |
67 | + { | |
68 | + logger.Debug("inside else in ForgotUserController userData= " + userData); | |
69 | + return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(userData)}; //new StringContent(userData) | |
57 | 70 | |
58 | 71 | } |
59 | 72 | } | ... | ... |
400-SOURCECODE/AIAHTML5.API/Models/ResetUser.cs
... | ... | @@ -12,14 +12,17 @@ using AIAHTML5.API.Utility; |
12 | 12 | using System.Text; |
13 | 13 | using System.IO; |
14 | 14 | using System.Net.Mime; |
15 | -using System.Configuration; | |
15 | +using System.Configuration; | |
16 | 16 | |
17 | 17 | namespace AIAHTML5.API.Models |
18 | 18 | { |
19 | 19 | public class ResetUser |
20 | 20 | { |
21 | 21 | public static bool SendEmail(dynamic UserDetails, bool isPassword) |
22 | - { | |
22 | + { | |
23 | + ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); | |
24 | + logger.Debug("inside SendEmail in for isPassword =" + isPassword); | |
25 | + | |
23 | 26 | try |
24 | 27 | { |
25 | 28 | List<LinkedResource> lstLinkedResource = new List<LinkedResource>(); |
... | ... | @@ -63,15 +66,16 @@ namespace AIAHTML5.API.Models |
63 | 66 | resetPasswordLink = site_url + "?em:" + HttpUtility.UrlEncode(userMail); |
64 | 67 | } |
65 | 68 | else |
66 | - templatePath = "~/Templates/forgot-UserId.html"; | |
67 | - | |
69 | + templatePath = "~/Templates/forgot-UserId.html"; | |
70 | + | |
71 | + logger.Debug("inside SendEmail for templatePath= " + templatePath + ", userId= " + userId + ", userMail= " + userMail + ",fullName= " + fullName + ",resetPasswordLink= " + resetPasswordLink); | |
68 | 72 | string mailBody = ResetUser.GetMailBodyTextFromTemplate(templatePath, userId, userMail, fullName, resetPasswordLink); |
69 | 73 | |
70 | 74 | lstToAddress.Add(userMail); |
71 | 75 | |
72 | - emailText = mailBody; | |
73 | - | |
74 | - | |
76 | + emailText = mailBody; | |
77 | + | |
78 | + logger.Debug("emailText= " + emailText); | |
75 | 79 | // for embedding images in email |
76 | 80 | if (emailText.Contains("<img")) |
77 | 81 | { |
... | ... | @@ -92,9 +96,9 @@ namespace AIAHTML5.API.Models |
92 | 96 | if(!isPassword) |
93 | 97 | mailSubject = "UserID recovery mail for: "; |
94 | 98 | else |
95 | - mailSubject = "Password recovery mail for: "; | |
96 | - | |
97 | - emailUtility.sHostName = "10.100.12.13"; | |
99 | + mailSubject = "Password recovery mail for: "; | |
100 | + | |
101 | + emailUtility.sHostName = Convert.ToString(ConfigurationManager.AppSettings["HostAddress"]); | |
98 | 102 | emailUtility.sFromAddress = Convert.ToString(ConfigurationManager.AppSettings["SenderEmailAddress"]); |
99 | 103 | emailUtility.bIsBodyHtml = true; |
100 | 104 | emailUtility.bEnableSsl = false; |
... | ... | @@ -115,7 +119,10 @@ namespace AIAHTML5.API.Models |
115 | 119 | } |
116 | 120 | |
117 | 121 | protected static string GetMailBodyTextFromTemplate(string templatePath, string userId, string userMail, string fullName, string resetPasswordUrl) |
118 | - { | |
122 | + { | |
123 | + ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); | |
124 | + logger.Debug("inside GetMailBodyTextFromTemplate for templatePath= " + templatePath + ", userId= " + userId + ", userMail= " + userMail + ",fullName= " + fullName + ",resetPasswordLink= " + resetPasswordUrl); | |
125 | + | |
119 | 126 | string fileToRead = string.Empty; |
120 | 127 | string emailBody = string.Empty; |
121 | 128 | try |
... | ... | @@ -138,7 +145,8 @@ namespace AIAHTML5.API.Models |
138 | 145 | } |
139 | 146 | catch (Exception e) |
140 | 147 | { |
141 | - emailBody = "Exception: " + e.Message; | |
148 | + emailBody = "Exception: " + e.Message; | |
149 | + logger.Fatal("exception in GetMailBodyTextFromTemplate. msg= " + e.Message + ", stacktrace= " + e.StackTrace); | |
142 | 150 | } |
143 | 151 | return emailBody; |
144 | 152 | } | ... | ... |
400-SOURCECODE/AIAHTML5.API/Models/Users.cs
... | ... | @@ -55,6 +55,7 @@ namespace AIAHTML5.API.Models |
55 | 55 | internal static dynamic GetUserByEmail(Newtonsoft.Json.Linq.JObject userInfo) |
56 | 56 | { |
57 | 57 | ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); |
58 | + logger.Debug(" inside GetUserByEmail for emailId = " + userInfo["emailId"] ); | |
58 | 59 | var client = new MongoClient(); |
59 | 60 | |
60 | 61 | try |
... | ... | @@ -67,15 +68,21 @@ namespace AIAHTML5.API.Models |
67 | 68 | FilterDefinition<dynamic> filterCondition = Builders<dynamic>.Filter.Eq("emailId", userInfo["emailId"].ToString().ToLower()); |
68 | 69 | |
69 | 70 | dynamic userDetails = collection.Find(Builders<dynamic>.Filter.And(filterCondition)).SingleOrDefault(); |
70 | - | |
71 | 71 | if (userDetails != null) |
72 | + { | |
73 | + logger.Debug("userDetails= " + userDetails.loginId); | |
74 | + | |
72 | 75 | return userDetails; |
76 | + } | |
73 | 77 | else |
78 | + { | |
79 | + logger.Debug("user not found"); | |
74 | 80 | return AIAConstants.USER_NOT_FOUND; |
81 | + } | |
75 | 82 | } |
76 | 83 | catch (Exception e) |
77 | 84 | { |
78 | - logger.Fatal("Exception= " + e.Message); | |
85 | + logger.Fatal("Exception= " + e.Message+", stacktrace = "+e.StackTrace); | |
79 | 86 | return AIAConstants.ERROR_IN_FECTHING_DETAILS; |
80 | 87 | } |
81 | 88 | } | ... | ... |
400-SOURCECODE/AIAHTML5.API/Utility/EmailUtility.cs
... | ... | @@ -7,7 +7,8 @@ using System.Collections; |
7 | 7 | using System.Xml; |
8 | 8 | using System.Text; |
9 | 9 | using System.IO; |
10 | -using System.Net.Mail; | |
10 | +using System.Net.Mail; | |
11 | +using log4net; | |
11 | 12 | |
12 | 13 | namespace AIAHTML5.API.Utility |
13 | 14 | { |
... | ... | @@ -41,7 +42,10 @@ namespace AIAHTML5.API.Utility |
41 | 42 | } |
42 | 43 | |
43 | 44 | public void SendSmtpEmail() |
44 | - { | |
45 | + { | |
46 | + ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); | |
47 | + logger.Debug("inside SendSmtpEmail"); | |
48 | + | |
45 | 49 | try |
46 | 50 | { |
47 | 51 | MailMessage sMail = new MailMessage(); |
... | ... | @@ -53,8 +57,8 @@ namespace AIAHTML5.API.Utility |
53 | 57 | { |
54 | 58 | foreach (var sItem in sToAddresses) |
55 | 59 | { |
56 | - sMail.To.Add(sItem); | |
57 | - | |
60 | + sMail.To.Add(sItem); | |
61 | + logger.Debug("sToAddresses= " + sItem); | |
58 | 62 | } |
59 | 63 | } |
60 | 64 | |
... | ... | @@ -62,7 +66,9 @@ namespace AIAHTML5.API.Utility |
62 | 66 | { |
63 | 67 | foreach (var sItem in sBccAddresses) |
64 | 68 | { |
65 | - sMail.Bcc.Add(sItem); | |
69 | + sMail.Bcc.Add(sItem); | |
70 | + logger.Debug("sBccAddresses= " + sItem); | |
71 | + | |
66 | 72 | } |
67 | 73 | } |
68 | 74 | |
... | ... | @@ -70,21 +76,31 @@ namespace AIAHTML5.API.Utility |
70 | 76 | |
71 | 77 | if (sAlternateView != null) |
72 | 78 | { |
73 | - sMail.AlternateViews.Add(sAlternateView); | |
79 | + sMail.AlternateViews.Add(sAlternateView); | |
80 | + logger.Debug("sAlternateView= " + sAlternateView); | |
81 | + | |
74 | 82 | } |
75 | 83 | else |
76 | 84 | { |
77 | - sMail.Body = sBodyText; | |
85 | + sMail.Body = sBodyText; | |
86 | + logger.Debug("sMail.Body= " + sBodyText); | |
87 | + | |
78 | 88 | } |
79 | 89 | |
80 | - sMail.Subject = sSubject; | |
90 | + sMail.Subject = sSubject; | |
91 | + logger.Debug("sMail.Subject= " + sSubject); | |
92 | + | |
81 | 93 | if (sAttachments != null) |
82 | 94 | { |
83 | 95 | foreach (var sItem in sAttachments) |
84 | 96 | { |
85 | - sMail.Attachments.Add(sItem); | |
97 | + sMail.Attachments.Add(sItem); | |
98 | + logger.Debug("sAttachments= " + sAttachments); | |
99 | + | |
100 | + | |
86 | 101 | } |
87 | - } | |
102 | + } | |
103 | + logger.Debug("sUserName= " + sUserName + ", sPassword= " + sPassword); | |
88 | 104 | |
89 | 105 | SmtpServer.Port = iPort; |
90 | 106 | SmtpServer.Credentials = new System.Net.NetworkCredential(sUserName, sPassword); |
... | ... | @@ -105,12 +121,14 @@ namespace AIAHTML5.API.Utility |
105 | 121 | } |
106 | 122 | |
107 | 123 | mm.IsBodyHtml = true; |
108 | - SendMail(mm); | |
124 | + SendMail(mm); | |
125 | + logger.Debug("after sending email"); | |
109 | 126 | } |
110 | 127 | |
111 | 128 | } |
112 | 129 | catch (Exception ex) |
113 | - { | |
130 | + { | |
131 | + logger.Fatal("exception in SendSmtpEmail.msg= " + ex.Message + ", stacktarce= " + ex.StackTrace); | |
114 | 132 | throw ex; |
115 | 133 | } |
116 | 134 | } | ... | ... |
400-SOURCECODE/AIAHTML5.API/Web.config
... | ... | @@ -37,8 +37,8 @@ |
37 | 37 | <add key="SMTPAddress" value="smtp.emailsrvr.com" /> |
38 | 38 | <add key="SMTPPort" value="587" /> |
39 | 39 | <add key="EnableSSL" value="false" /> |
40 | - <add key="NotifyEmailAddress" value="support@interactiveanatomy.com" /> | |
41 | 40 | <add key="Site_Url" value ="//52.2.38.120"/> |
41 | + <add key ="HostAddress" value="10.100.12.13" /> | |
42 | 42 | </appSettings> |
43 | 43 | <system.web> |
44 | 44 | <compilation debug="true" targetFramework="4.5" /> | ... | ... |
400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll
No preview for this file type
400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll.config
... | ... | @@ -39,6 +39,7 @@ |
39 | 39 | <add key="EnableSSL" value="false" /> |
40 | 40 | <add key="NotifyEmailAddress" value="support@interactiveanatomy.com" /> |
41 | 41 | <add key="Site_Url" value ="//52.2.38.120"/> |
42 | + <add key ="HostAddress" value="10.100.12.13" /> | |
42 | 43 | </appSettings> |
43 | 44 | <system.web> |
44 | 45 | <compilation debug="true" targetFramework="4.5" /> |
... | ... | @@ -48,7 +49,7 @@ |
48 | 49 | <applicationSettings> |
49 | 50 | <AIAHTML5.API.Properties.Settings> |
50 | 51 | <setting name="AIAConnectionString" serializeAs="String"> |
51 | - <value>192.168.90.157:27017</value> | |
52 | + <value>localhost:27017</value> | |
52 | 53 | </setting> |
53 | 54 | <setting name="database" serializeAs="String"> |
54 | 55 | <value>AIA</value> | ... | ... |
400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.pdb
No preview for this file type
400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js
... | ... | @@ -179,7 +179,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic |
179 | 179 | $rootScope.SendMailToUser = function (userInfo, isMailForPassword) { |
180 | 180 | if ((userInfo.emailId != null) && (userInfo.emailId != '')) { |
181 | 181 | if (validateEmail(userInfo.emailId)) { |
182 | - if (isMailForPassword == 'true') | |
182 | + if (isMailForPassword == true) | |
183 | 183 | userInfo.isPassword = true; |
184 | 184 | else |
185 | 185 | userInfo.isPassword = false; |
... | ... | @@ -187,10 +187,13 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic |
187 | 187 | AuthenticationService.SendMailToUser(userInfo) |
188 | 188 | .then(function (result) { |
189 | 189 | if (result == LoginConstants.USER_NOT_FOUND) { |
190 | - alert("Error occured."); | |
190 | + alert(LoginConstants.USER_NOT_FOUND); | |
191 | 191 | } |
192 | 192 | else if (result == LoginConstants.ERROR_IN_FECTHING_DETAILS) { |
193 | - alert("Error occured."); | |
193 | + alert("An error occured."); | |
194 | + } | |
195 | + else if (result == LoginConstants.MAIL_NOT_SENT) { | |
196 | + alert("Due to some issue, email not sent."); | |
194 | 197 | } |
195 | 198 | else { |
196 | 199 | if (result.loginId != undefined || result.loginId != "" || result.loginId != null) { | ... | ... |
400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js
... | ... | @@ -283,6 +283,7 @@ AIA.constant('ImageTypes', ['Illustration', 'Cadaver Photograph', 'Radiograph']) |
283 | 283 | AIA.constant("LoginConstants", { |
284 | 284 | "USER_NOT_FOUND": "User not found.", |
285 | 285 | "ERROR_IN_FECTHING_DETAILS": "Error in fecthing details.", |
286 | + "MAIL_NOT_SENT" : "Mail not sent.", | |
286 | 287 | |
287 | 288 | }) |
288 | 289 | ... | ... |
400-SOURCECODE/AIAHTML5.Web/index.html
... | ... | @@ -243,7 +243,7 @@ |
243 | 243 | </form> |
244 | 244 | </div> |
245 | 245 | <div class="modal-footer"> |
246 | - <button type="button" class="btn btn-primary btn-block" ng-click="SendMailToUser(userInfo, 'false')">Send Mail</button> | |
246 | + <button type="button" class="btn btn-primary btn-block" ng-click="SendMailToUser(userInfo, false)">Send Mail</button> | |
247 | 247 | </div> |
248 | 248 | <!--<div style="color: maroon; font-weight: bold; " ng-if="message">{{message}}</div>--> |
249 | 249 | </div> |
... | ... | @@ -268,7 +268,7 @@ |
268 | 268 | </form> |
269 | 269 | </div> |
270 | 270 | <div class="modal-footer"> |
271 | - <button type="button" class="btn btn-primary btn-block" ng-click="SendMailToUser(userInfo, 'true')">Send Mail</button> | |
271 | + <button type="button" class="btn btn-primary btn-block" ng-click="SendMailToUser(userInfo, true)">Send Mail</button> | |
272 | 272 | </div> |
273 | 273 | <!--<div style="color: maroon; font-weight: bold; " ng-if="message">{{message}}</div>--> |
274 | 274 | </div> | ... | ... |